callbackReadForm

callbackReadForm(callable $callback)

This callback is used in case you need to change the representation of the value on view form.

At the below example, the url always need to start with http:// or https://. In case that the url starts does not start with http:// or https:// then we are adding it at the beginning of the string. The implementation of the example is as follows:

$crud->callbackReadForm(function ($data) {
    if (substr($data['url'], 0, 7) !== 'http://' && substr($data['url'], 0, 8) !== 'https://') {
        $data['url'] = 'http://' . $data['url'];
    }

    return $data;
});