Magento 2 : Form component

Posted . Visible to the public.

Custom time component

Magento2 time component does not pass the selected time when post the form to controller.
Following custom time component is used to capture the time.

In form xml

<field name="start_time" formElement="input">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="source" xsi:type="string">milestone</item>
                </item>
            </argument>
            <settings>
                <elementTmpl>Vasan_Bidding/form/element/time_input</elementTmpl>
                <dataType>text</dataType>
                <visible>true</visible>
                <dataScope>start_time</dataScope>
                <label translate="true">Start Time</label>
                <validation>
                    <rule name="required-entry" xsi:type="boolean">false</rule>
                </validation>
            </settings>
        </field>

In html



<input class="admin__control-text" type="time"
       data-bind="
        event: {change: userChanges},
        value: value,
        hasFocus: focused,
        valueUpdate: valueUpdate,
        attr: {
            name: inputName,
            placeholder: placeholder,
            'aria-describedby': noticeId,
            id: uid,
            disabled: disabled,
    }"/>

vasan
Last edit
vasan
Posted by vasan to vasan's deck (2022-03-25 02:47)