PHP code example of dnadesign / silverstripe-advanceddropdowns
1. Go to this page and download the library: Download dnadesign/silverstripe-advanceddropdowns library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
dnadesign / silverstripe-advanceddropdowns example snippets
new AdvancedDropdownField('AdvancedDropdown', 'DropdownField with option attributes', array(
'value1' => array(
'Title' => 'Option 1',
'Attributes' => array(
'data-myattribute' => 'This is an attribute value'
)
),
'value2' => array(
'Title' => 'Option 2',
'Attributes' => array(
'data-myattribute' => 'This is an attribute value'
'data-myattribute2' => 'This is a second attribute value'
)
)
));
new AdvancedGroupedDropdownField('AdvancedGroupedDropdown', 'Advanced grouped dropdown', array(
'value1' => array(
'Title' => 'Ungrouped option',
'Attributes' => array(
'data-myattribute' => 'This is an attribute value'
)
),
'Option group 1' => array(
'value2' => array(
'Title' => 'Option 2',
'Attributes' => array(
'data-myattribute' => 'This is an attribute value'
)
),
'value3' => array(
'Title' => 'Option 3',
'Attributes' => array(
'data-myattribute' => 'This is an attribute value'
)
)
),
'Option group 2' => array(
'value4' => array(
'Title' => 'Option 4',
'Attributes' => array(
'data-myattribute' => 'This is an attribute value'
)
),
'value5' => array(
'Title' => 'Option 5',
'Attributes' => array(
'data-myattribute' => 'This is an attribute value'
'data-myattribute2' => 'This is a second attribute value'
)
)
)
));