See an example from the core: «Catalog
» → «Storefront
» → «List Mode
»
The field XML declaration is:
Take note of:
type="select"
. It defined the dropdown control.
<source_model>Magento\Catalog\Model\Config\Source\ListMode</source_model>
. It defined the dropdown items.
class ListMode implements \Magento\Framework\Option\ArrayInterface
{
/**
* {@inheritdoc}
*
* @codeCoverageIgnore
*/
public function toOptionArray()
{
return [
['value' => 'grid', 'label' => __('Grid Only')],
['value' => 'list', 'label' => __('List Only')],
['value' => 'grid-list', 'label' => __('Grid (default) / List')],
['value' => 'list-grid', 'label' => __('List (default) / Grid')]
];
}
}
Gabe
(Gabor Suranyi)
November 19, 2015, 1:04pm
2
RC2 and after this method doesn’t work.
Any ideas why?
To be honest for me M2 doesn’t recognize right now ANY class that I declare in my module.
Just like a model\source\ file, \Helper\Data.php also goes unrecognized.
Thanks in advance!
The method described in the article works well with the both Release Candidates and with the Release.