I am creating custom widget in Magento 2. I have created widget.xml file to create this. All things are fine and widget option is showing as well in admin.
Only I want selected value "Yes" instead of "No". Right now it is "No" as default selected value.
Here is the code I am using for select box in widget.xml
<parameter name="chart_layout" xsi:type="select" visible="true" source_model="Magento\Config\Model\Config\Source\Yesno" sort_order="2">
<label translate="true">Full Width</label>
</parameter>
I am getting below section as screenshot.
1 Answer 1
If default values are not working for YesNo (I don't have time to dig) then you could always cheese the system for the time being and try to find a cleaner solution:
<parameter name="chart_layout" xsi:type="select" visible="true">
<label translate="true">Full Width</label>
<options>
<option name="yes" value="1" selected="true">
<label translate="true">Yes</label>
</option>
<option name="no" value="0">
<label translate="true">No</label>
</option>
</options>
</parameter>
-
Not working, I get following error: Element 'parameter', attribute 'value': The attribute 'value' is not allowedArshad Hussain– Arshad Hussain2016年12月06日 10:32:16 +00:00Commented Dec 6, 2016 at 10:32
-
I've changed the answer to allow for a temporary fix.Julien Lachal– Julien Lachal2016年12月06日 10:42:00 +00:00Commented Dec 6, 2016 at 10:42