I have a custom admin form, but i do not know how to create 2 differences field For example: i want to create 2 fields are: employee_number and employee_insurance But each field has a limit amount of number, employee_number can only insert number but it must has 6 character like 123456, while employee_insurance can only insert number but it must has 16 character like 1234567891234567. How can i make this and i really need help
1 Answer
Try This Code
......................................................................
......................................................................
......................................................................
<field name="employee_number" sortOrder="20" formElement="input">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="source" xsi:type="string">employee_number</item>
</item>
</argument>
<settings>
<validation>
<rule name="required-entry" xsi:type="boolean">true</rule>
<rule name="max_text_length" xsi:type="number">6</rule>
<rule name="min_text_length" xsi:type="number">6</rule>
</validation>
<dataType>text</dataType>
<label translate="true">Employee Number</label>
<dataScope>employee_number</dataScope>
</settings>
</field>
<field name="employee_insurance" sortOrder="20" formElement="input">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="source" xsi:type="string">Employee Insurance</item>
</item>
</argument>
<settings>
<validation>
<rule name="required-entry" xsi:type="boolean">true</rule>
<rule name="max_text_length" xsi:type="number">16</rule>
<rule name="min_text_length" xsi:type="number">16</rule>
</validation>
<dataType>text</dataType>
<label translate="true">Employee Insurance</label>
<dataScope>employee_insurance</dataScope>
</settings>
</field>
......................................................................
......................................................................
......................................................................
Output: https://prnt.sc/cWyFuPeXUPUN
-
Wow that pretty good, hey are you the guy who help answer this question: magento.stackexchange.com/questions/304319/…. Could you help me do the same but with ui component Commented Jul 22, 2022 at 10:05
-
Sure, i will accept it for you but can you help me with the upload CSV file ? Commented Jul 22, 2022 at 10:11
-
-
-
@KAITO_3SS Please download the file and the reference links are shared in that file. I hope this helps you. transfernow.net/dl/20220722X9oCm5Hx– MsquareCommented Jul 22, 2022 at 10:38