/

Field Grouping, Tabs & Rich Text

Break a long form into collapsible sections or tabs, and add a Quill rich-text editor field.

fields_arrange() - collapsible sections

->fields_arrange($fields, $groupLabel, $collapsed = false) groups fields into a labeled, collapsible section - a heading with an expand/collapse toggle, rather than a flat list. Call it once per group, in the order the groups should appear.

$xcrud->fields_arrange('firstName,lastName,email', 'Contact Info');
$xcrud->fields_arrange('addressLine1,city,postalCode', 'Address', true);
ParameterTypeDefaultDescription
$fieldsstring-Comma-separated fields belonging to this group
$groupLabelstring-Heading text shown above the group
$collapsedboolfalseWhen true, the group starts collapsed instead of expanded

fields() as a tab switcher

->fields() can also be called multiple times with $useTabs = true to build a tab switcher instead of one long form - each call becomes one tab, with $sectionName as that tab's label. Every field named across all calls stays whitelisted/editable exactly as a single fields() call would require.

$xcrud->fields('firstName,lastName,email', true, 'Contact');
$xcrud->fields('addressLine1,city,postalCode', true, 'Address');
$xcrud->fields('notes', true, 'Notes');

All fields() calls that name a section must agree on $useTabs (all tabbed, or all plain) - and tabbed sections are mutually exclusive with ->fields_arrange() on the same page. Plain (non-tab) sections combined with fields_arrange() is fine, since they don't compete for the same visual role.

When a table also uses nested_table() (which creates its own tab per child), ->default_tab($label, $order = null) labels the tab holding the table's own top-level fields, so it reads consistently alongside the nested-table tabs.

$xcrud->default_tab('Details', 1);
ParameterTypeDefaultDescription
$labelstring-Label for the table's own top-level fields tab
$order?intnullPosition of this tab relative to the nested-table tabs

See Nested Tables as Tabs for the nested-table side of this.

Rich text with the editor field type

change_type($field, 'editor') swaps a field's plain textarea for a Quill WYSIWYG rich-text editor, storing the result as HTML.

$xcrud->change_type('description', 'editor');

See Field Types Overview for the complete type list.

Putting it together

$xcrud = Xcrud::get_instance();
$xcrud->table('products');
$xcrud->route('products');

$xcrud->change_type('description', 'editor');

$xcrud->fields('productName,productLine,quantityInStock', true, 'Overview');
$xcrud->fields('description', true, 'Description');
$xcrud->fields('buyPrice,MSRP', true, 'Pricing');

$xcrud->render();