1

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 1

1

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

7
  • 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
    – KAITO_3SS
    Commented Jul 22, 2022 at 10:05
  • Sure, i will accept it for you but can you help me with the upload CSV file ?
    – KAITO_3SS
    Commented Jul 22, 2022 at 10:11
  • @KAITO_3SS Yes sure.
    – Msquare
    Commented Jul 22, 2022 at 10:12
  • Wow thank you, you are amazing
    – KAITO_3SS
    Commented Jul 22, 2022 at 10:13
  • @KAITO_3SS Please download the file and the reference links are shared in that file. I hope this helps you. transfernow.net/dl/20220722X9oCm5Hx
    – Msquare
    Commented Jul 22, 2022 at 10:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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