fields

fields(array $fields);

This is simply an alias of using addFields, editFields, readFields and cloneFields. This method was created as it is very common that at the add/edit/read/clone form to have the same fields.

So for example the below line of code:

$crud->fields(['first_name', 'last_name', 'address']);

is exactly the same as:

$crud->addFields(['first_name', 'last_name', 'address']);
$crud->editFields(['first_name', 'last_name', 'address']);
$crud->readFields(['first_name', 'last_name', 'address']);
$crud->cloneFields(['first_name', 'last_name', 'address']);

You can see a full working example below. At the below example as you will notice, we haven't added any columns so you can see that the fields are more than 4 at the datagrid but only 4 on each form layer (e.g. if you try to edit one row).

$crud->setTable('customers');
$crud->setSubject('Customer', 'Customers');
$crud->fields(['customerName', 'phone', 'addressLine1', 'creditLimit']);

$output $crud->render();

You can see the result of the above code here: