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_add_field

void callback_add_field( string $field , mixed $callback )
Quick Description: This callback escapes the default auto field output of the field name at the add form.

This callback escapes the default auto field output of the field name at the add form. There are no parameters to this callback. You must return to the callback function a string.

Example:

function example_callback_add_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_add_field('phone', function () {
        return '+30 <input type="text" maxlength="50" value="" name="phone">';
    });
    $crud->callback_add_field('state',function () {
        return '<input type="text" maxlength="50" value="" name="state"> ( for U.S. only )';
    });
 
    $output = $crud->render();
 
    $this->_example_output($output);
}
Note: The below example is an iframe so it might appeared with a scroll bar. If you like you can view the example on a new tab