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:
-
tabs
- As tabs:
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"/>
- 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.
Deprecated Grouping Method
This method is not recommended for use and will be removed in the future.
To group fields into a section, you need to specify the following attributes in their properties:
sectionIdent
- unique section namesectionCaption
- Section heading that will be displayed to the user
<field type="text"
name="website"
caption="<?php echo __('Website');?>"
filter="text"
sectionIdent="contact"
sectionCaption="<?php echo __('Contact'); ?>" />
<field type="text"
name="phone"
caption="<?php echo __('Sales Phone')?>"
width="15%"
required="true"
disclaimer="<?php echo __('Format: (555) 787-4567');?>"
sectionIdent="contact"
sectionCaption="<?php echo __('Contact'); ?>" />