Field Grouping

In forms, you can group fields by some common characteristics, specifically by combining them into sections.

To create sections, add:

<sections mode="widgets">
  <section name="general" caption="<?php echo __('General');?>"/>
  <section name="settings" caption="<?php echo __('Settings');?>"/>
</sections>

Sections can work in 2 modes (mode): - widgets - As widgets: DGS Fields Sections - tabs - As tabs: DGS Fields Sections

To divide fields into sections, you need to add the sections element and set the section property for the needed fields:

<field type="text" 
       clicable="true" 
       name="caption"
       caption="<?php echo __('Dealership Name')?>"
       filter="text"
       sorting="yes"
       required="true"
       section="general" />

<field type="file"
       name="logo"
       caption="<?php echo __('Logo')?>"
       fileName="__ID__.__EXT__"
       isnull="true"
       uploadDirPath="<?php echo Core::getInstance()->config['paths']['dealers_logo']; ?>"
       httpPath="<?php echo Core::getInstance()->config['http_paths']['dealers_logo']; ?>"
       section="general" />

<field type="text"
       name="website"
       caption="<?php echo __('Website');?>"
       filter="text"
       section="general" />

<field type="text"
       name="phone"
       caption="<?php echo __('Sales Phone')?>"
       width="15%"
       required="true"
       section="general" />

<field type="sql"
       query="import_resources.caption"
       name="import_provider"
       caption="<?php echo __('Import Provider')?>"
       width="10%"
       section="settings" />

<field type="foreignKey"
       name="website_provider"
       caption="<?php echo __('Website Provider'); ?>"
       foreignTable="website_providers"
       foreignKeyField="ident"
       foreignValueField="caption"
       allowEmpty="true"
       isnull="true"
       section="settings" />

<field type="checkbox"
       name="is_script_works"
       caption="<?php echo __('Is Script Works')?>"
       isnull="true"
       filter="yes"
       width="10%"
       section="settings" />

<field type="text"
       name="email"
       caption="<?php echo __('E-mail')?>"
       filter="text"
       sorting="true"
       hide="true"
       required="true"
       section="general" />

<field type="text"
       name="contact_email"
       caption="<?php echo __('Sales Email')?>"
       section="general"/>

DGS Fields Sections

  • In tabs mode, all fields without sections are automatically added to the first section.

If you need to disable sections for specific actions, you can either remove them by reference from the DGS model or set false for the sections key in the Store::EVENT_ON_FETCH_FORM event.

When you use sections and don't set the section property for some fields, they will be added to the first section by default.

In widgets mode, you can specify the number of columns for sections by adding the columns attribute to the sections element:

<sections mode="widgets" columns="2">
  <section name="general" caption="<?php echo __('General');?>"/>
  <section name="settings" caption="<?php echo __('Settings');?>"/>
</sections>