-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Description
Even if the differences between a select an multiselect should be only 'multiple="multiple"' and the way that the selected value is determined the classes that render these elements behave differently:
I can define a select element like this:
$fieldset->addField(
'some_id',
'select',
array(
'name' => 'some_name',
'label' => __('Some Label'),
'title' => __('Some Label'),
'options' => array(
'val1' => 'Label 1',
'val2' => 'Label 2',
)
)
);
but the multiselect element must be defined like this:
$fieldset->addField(
'some_id',
'multiselect',
array(
'name' => 'some_name',
'label' => __('Some Label'),
'title' => __('Some Label'),
'values' => array(
array(
'value' => 'val1',
'label' => 'label 1',
),
array(
'value' => 'val2',
'label' => 'label 2',
)
)
)
);
Notice that for the select I can pass 'options' (it works with values also) but for multiselect I have to pass 'values'. And the format for the options array is different from the values array.
I think that the Magento\Framework\Data\Form\Element\Multiselect class should extend Magento\Framework\Data\Form\Element\Select. This way it can use the _prepareOptions method and handle the 'options' setting.
I realize that this is not a critical issue, but consistency is good. 😄