Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Declaring requiredIf validadors in DS XML files?

    Hi there,

    Is there a way to declare a RequiredIf validator right in the DS XML file?
    If yes, than what is the required syntax?

    Thank you for your help:

    Csillag

    #2
    Whether in the .ds.xml file or not, using this validator requires writing the validation logic in JavaScript, so we'd recommend just using a custom validator instead for SmartGWT.

    Comment


      #3
      Writing the validation logic in JS is not necessarily a problem, especially when it's dead simple like "when the value of field A is B, the field C is required".

      I just need one example for the proper syntax.

      Thank you:

      Csillag

      Comment


        #4
        Straightforward:
        Code:
        <DataSource ID="requiredIfTest">
            <fields>
                <field name="required" title="Require email?" type="boolean" />
                <field name="email" title="Email address" type="text">
                  <validators>
                    <validator type="requiredIf" expression="item.form.getValue('required')" errorMessage="Please enter an email address"/>
                  </validators>
                </field>
            </fields>
        </DataSource>
        The email field is only required when the required checkbox is checked.

        Comment


          #5
          It's working great, thank you.

          Comment

          Working...
          X