Multi Select Field

../../_images/multiselect.jpeg

XML Configuration

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:module:Leonex_SiteBuilder:etc/lnx_sitebuilder.xsd">
    <element>
        ...
        <fields>
            <multiselect code="field_code"
                    class="Leonex\SiteBuilderExample\ViewModel\Field\Field"
                    position="1"
                    enabled="true"
                    list="false">
                <label translate="true">Custom Field</label>
                <tooltip translate="true">Custom Tooltip Text</tooltip>
                <notice translate="true">Custom Notice Text</notice>
                <validation>
                    <!-- Magento Validation Rules -->
                    <validate name="required-entry" enabled="true" />
                </validation>
                <!-- Provide Options -->
                <options>
                    <option value="1" translate="true">Option 1</option>
                    <option value="2" translate="true">Option 3</option>
                </options>
                <!-- OR -->
                <source class="Magento\Config\Model\Config\Source\Yesno" />
            </multiselect>
        </fields>
    </element>
</config>
Field Attribute Information
Name Value Type Default Value Required Description
code String No Default Value Yes Field Code, needs to be unique. Is used later in the template to get the data for this field.
class String / Php Class ArrayField [1] No Adds a custom Php ViewModel for this field. The Php Class must conform to the Leonex\SiteBuilder\Api\ViewModel\FieldInterface
position Integer MAX_INT No Position of the field inside the Element Configuration
enabled Boolean (“true” or “false”) true No Enables or Disables the field for the current element
list Boolean (“true” or “false”) false No If set to true the element can hold a list of the current field
[1]Namespace: Leonex\SiteBuilder\ViewModel\Field
Field Tag Information
Name Required Description
label Yes The Label of the field
tooltip No A Tooltip text which is shown left to the field
notice No A Notice which is shown below the field
validation No Validation Rules which should be applied to the filed value. A list of validation rules can be found here: https://mage2.pro/t/topic/356
defaultValue No The default Value of this element
options Yes [2] Provides the options for this field.
source Yes [2] Provides the options for this field. The Class needs to implement the Magento\Framework\Data\OptionSourceInterface Interface
[2](1, 2) You can only use an option tag or a source tag, not both at the same time