fieldTypeColumn

fieldTypeColumn(string $columnName, string|ModelFieldType $fieldType[, array $permittedValues[, array $options]])

This function is used for cases that you need to change the field type but only for the column (e.g. not for add/edit/read form). You can choose any field type from the list of field types.

Example

Let's say that we need to show a field that by default is datetime field but on the columns we would like to show it as date (remove the time from the columns).

In order to do that any of the of the below 2 examples have the exact same results:

$crud->fieldTypeColumn('order_datetime', GroceryCrud::FIELD_TYPE_DATE);

or:

$crud->fieldTypeColumn('order_datetime', 'date');

And the above example will safely change the fieldType but only for the columns of the datagrid.

Example

$crud->setTable('orders');
$crud->setSubject('Order', 'Orders');
$crud->setRelation('customerNumber','customers','contactLastName');
$crud->displayAs('customerNumber','Customer');
$crud->unsetAdd();
$crud->unsetDelete();

// We are hiding requiredDate only on the columns. We can edit or
// filter the value of requiredDate
$crud->fieldTypeColumn('requiredDate', 'invisible');