0

I have created a dynamicRows component for Customer Edit Form. For some reason, if I set visible to false on the field "position", when I submit a new record, the position is never part of the data array.

<field name="position">
                <argument name="data" xsi:type="array">
                    <item name="config" xsi:type="array">
                        <!-- item name="source" xsi:type="string">customer</item -->
                        <item name="dataType" xsi:type="string">number</item>
                        <item name="formElement" xsi:type="string">input</item>
                        <item name="componentType" xsi:type="string">field</item>
                        <item name="label" xsi:type="string" translate="true">Position</item>
                        <item name="dataScope" xsi:type="string">position</item>
                        <item name="visible" xsi:type="boolean">false</item>
                    </item>
                </argument>
            </field>

When the field is visible, then the key "position" is provided and everything works perfect, but I prefer this field to stay hidden. This only happens when adding a new row.

Any thoughts?

1

i just have the same issue, in the magento documentation if we set visible to false, it should apply a css class to display none, but it's not the case. What i did is use and hidden input. Like that :

<field name="position" formElement="hidden">
     <argument name="data" xsi:type="array">
             <item name="config" xsi:type="array">
                  <item name="prefixName" xsi:type="string">option.order</item>
                  <item name="prefixElementName" xsi:type="string">option_</item>
              </item>
     </argument>
</field>

But the problem now is that the thead is still displayed and render the table quite ugly. So in your component you can use your own template :

<dynamicRows name="slide" template="MyNamespace_MyModule/dynamic-rows/templates/default">

And then in your custom template just change the condition to display the thead.

Hope it helps ! :)

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.