fieldTypeReadForm
fieldTypeReadForm(string $fieldName, string|ModelFieldType $fieldType[, array $permittedValues[, array $options]])
This function is used when you need to change the field type but only for the read/view form. You can choose any field type from the list of field types.
Any of the of the below 2 examples have the exact same results:
$crud->fieldTypeReadForm('date_of_birth', GroceryCrud::FIELD_TYPE_DATE);
or:
$crud->fieldTypeReadForm('date_of_birth', 'date');
You can also use the ModelFieldType object as an input. For example:
// At the beginning of the file
use GroceryCrud\Core\Model\ModelFieldType;
...
// At your code
$myField = new ModelFieldType();
$myField->setDataType(GroceryCrud::FIELD_TYPE_DATE);
$myField->setIsNullable(true);
$crud->fieldTypeReadForm('date_of_birth', $myField);
The default value of the ModelFieldType
object is 'varchar'
so for example if you have the below line:
$crud->fieldTypeReadForm('date_of_birth', new ModelFieldType());
or:
$myField = new ModelFieldType();
$crud->fieldTypeReadForm('date_of_birth', $myField);
the field type for read form will be varchar