Announcement

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

    Skip form validation conditionally

    Hi all,

    I'm using SmartGWT 2.3 pro and I have the following requirement.

    I have a form with several FormItems to manipulate a DataSource record.

    Each form item may or may not have a validation set.

    For all items I want to implement the following rule (pseudo code):

    if (value_of_item = 'BLAH') {
    skip validation
    }
    else {
    do normal validation
    }

    Is this at all possible?

    Regards,

    Kees.

    #2
    Can you explain a bit more about the use case? It sounds like you just want to turn validation off entirely - if so, you can set neverValidate (at least on a ListGrid).

    Comment


      #3
      The use case is pretty easy to explain: mimic the functionality in iTunes of editing metadata of multiple songs!

      We select multiple records from a listgrid and click "edit". A dialog shows up with a form showing the fields of the records.

      When a field has the same value for ALL the selected objects, it should show the value.

      When a field has different values in the selected objects it should show "[Multiple values]".

      On submitting the form, all fields with "[Multiple values]" should be disregarded and also should NOT be validated (because "[Multiple values]" is of course not a valid date for example).

      We cannot figure out how to implement this.

      Another way would be to do it EXACTLY like itunes and skip the "[Multiple values]" but add a checkbox to each FormItem... this seems even harder.

      Any suggestions?

      See attached iTunes screenshot as an example!
      Attached Files

      Comment


        #4
        You probably do not want to start from an ordinary databound DynamicForm in this use case since the behaviors are more different than similar. Consider that saving is going to involve updates to several different records, validation will need to separately validate multiple records, etc.

        One approach would be to have a hidden DynamicForm that is databound, and that you use to validate each record in turn, combining and propagating validation errors to the form that is displayed to the user.

        If you prefer the whole problem to be solved for you and wrapped up as a component, consider Feature Sponsorship - this would qualify.

        Comment

        Working...
        X