In case you've missed it, you are looking at an older version of the website. Checkout our latest version, we promise you will love it 😍

callback_field

void callback_field( string $field ,mixed $callback )
Quick Description: This callback escapes the default auto field output of the field name for the add and edit form.

callback_field is just a shortcut to callback_add_field and callback_edit_field.

So for example if you have:

$crud->callback_field('phone',array($this,'example_callback'));
is similar to:
 
$crud->callback_add_field('phone',array($this,'example_callback'));
$crud->callback_edit_field('phone',array($this,'example_callback'));
 

Example:

function example_callback_field(){
    $crud = new grocery_CRUD();
 
    $crud->set_table('offices');
    $crud->set_subject('Office');
    $crud->required_fields('city');
    $crud->columns('city','country','phone','addressLine1','postalCode');
 
    $crud->callback_field('phone',array($this,'field_callback_1'));
 
    $output = $crud->render();
 
    $this->_example_output($output);
}
 
function field_callback_1($value = '', $primary_key = null)
{
    return '+30 <input type="text" maxlength="50" value="'.$value.'" name="phone" style="width:462px">';
}