Skip to content

Getting error when options set for a field #3

@rajeev-k-tomy

Description

@rajeev-k-tomy

Problem

In the form layout xml file, when the options are set for a field as shown in the example,

<item name="is_active" xsi:type="array">
    <item name="field_type" xsi:type="string">select</item>
    <item name="sort_order" xsi:type="number">1</item>
    <item name="options" xsi:type="string">Magento\Config\Model\Config\Source\Yesno</item>
</item>

getting an error in the frontend like:

$options is not a proper instance: string

When I tried below:

    <item name="options" xsi:type="object">Magento\Config\Model\Config\Source\Yesno</item>

getting a different error in that case:

Instance of Magento\Framework\View\Element\Block\ArgumentInterface is expected, got Magento\Config\Model\Config\Source\Yesno instead.


Technical Details

Error is thrown from view/adminhtml/templates/form/field_type/select.phtml

$options = $field->getOptions();
...
if (false === $options instanceof OptionSourceInterface) {
    echo '$options is not a proper instance: '.gettype($options);
    return;
}

It seems $options is not resolved here.


Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions