callbackEditField(string $fieldName, callable $callback)

Create a custom field with a callback for edit/update form. As parameters we are getting two parameters:

  1. The value of the field from the database for that row
  2. The primary key value of the row in case you need to use it for an extra manual query

For example:

$crud->callbackEditField('telephone_number', function ($fieldValue, $primaryKeyValue, $rowData) {
    return '+30 <input name="telephone_number" value="' . $fieldValue . '"  />';

Have in mind that from PHP 5.4 and later there is an extra functionality with keywork use, so that means that you can pass any extra parameters at the callback from outside the callback if you wish it. For example:

$username = 'john';
$crud->callbackEditField('telephone_number', function ($fieldValue, $primaryKeyValue, $rowData) use ($username) {
     // You have access now at the extra custom variable $username
    return '+30 <input name="telephone_number" value="' . $fieldValue . '"  /> for: ' . $username ;

Notice: Grocery CRUD Enterprise is all about security so we are obliged to inform you that the callbackEditField is using the: dangerouslySetInnerHTML function of reactJS. As you can understand from the name, this may be very dangerous if it is not used properly. We are suggesting to use it mainly in admin environments and make sure that you are always filtering your data at the callback. This was the only way that we could enable the functionality of callbackEditField and you have to be aware of this warning before using it.