Blob representation in admin field

edited January 2014 in Share
I'm implementing ion-auth's user table into Fuel's admin, and that library stores the ip_address field as a blob.

I'm trying to think how to represent this as a field. The value has to be run through inet_ntop() to get the string value, and otherwise the fields show a non-ascii character. I can put the decoded value into 'after_html', but that solution still has the blob char represented. Ideally, I'd like to have a label for the field, the actual value in a hidden input, but don't want the Fuel fields rendering the stored value. The 'custom' field type might be the solution, but when I try it in my user_model, (as per the docs) I get:

call_user_func() expects parameter 1 to be a valid callback, function 'my_custom_field' not found or invalid function name

Comments

  • edited 4:54PM
    What does it look like in your form_fields method and is this a function you have access to in your current PHP environment (was reading that it didn't become available for Windows until 5.3).
  • edited 4:54PM
    I'm using PHP 5.4.

    I got the error using the example in the docs - literally the same code, just to see if it worked as expected. In form_fields():

    $fields['ip_address'] = array('type' => 'custom', 'func' => 'my_custom_field', 'display_label' => FALSE);

    Then in the same model:

    function my_custom_field($params) { $form_builder =& $params['instance']; $str = $form_builder->create_checkbox($params).' <label for="custom_example">Select this checkbox</label>'; return $str; }

    Admittedly, I'm not sure what is being passed in $params!

    The error (again) is:
    call_user_func() expects parameter 1 to be a valid callback, function 'my_custom_field' not found or invalid function name
  • edited 4:54PM
    If you are putting it in the same model, you'll need to use an array for the func (its using the call_user_func PHP function):
    $fields['ip_address'] = array('type' => 'custom', 'func' => array($this, 'my_custom_field'), 'display_label' => FALSE);
  • edited 4:54PM
    I like!
Sign In or Register to comment.