1. Fabrik 3.9 has been released. If you have updated Joomla to 3.9, this is a required update.
    Dismiss Notice

ajax validation + trigger submit + "Repeat Num Element" = problem

Discussion in 'Community' started by mirceat, Nov 8, 2018.

  1. mirceat

    mirceat Member

    Level: Community
    Hello,

    I have a main group "Services" with few dbjoin/cdd elements + a calc element named "Counter" that calculate the number of records in database based on dbjoins selections.

    "Attached" to this main group there is a repeat group called "Tarrifs" that include a single field element. This field is set to be repeated in this group as many times as "Counter" value.

    All the elements in form have a notempty validation with "Must validate" set to Yes (both for new and edit).

    The form is set to use the Ajax Validation and Toogle submit button if any validation failed.

    The problem: the Submit button is not activated even if all validations pass. If i unset the "Must validate" option for the field element or if i don't use the "Counter" for the repeated group - so the field is no longer repeated-, then the submit button is available.

    Thank you
     
  2. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    I seem to recall some issue with using a calc as the "counter" for the repeats.

    What happens if you test with a simple static element for the counter, like a dropdown with numeric values?

    -- hugh
     
  3. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    I seem to recall some issue with using a calc as the "counter" for the repeats.

    What happens if you test with a simple static element for the counter, like a dropdown with numeric values?

    -- hugh
     
  4. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    I seem to recall some issue with using a calc as the "counter" for the repeats.

    What happens if you test with a simple static element for the counter, like a dropdown with numeric values?

    -- hugh
     
  5. mirceat

    mirceat Member

    Level: Community
    yes, works fine with a static value, but i need to be dynamic, the "tariffs" are very different for each "services"..
     
  6. mirceat

    mirceat Member

    Level: Community
    friendly bump..
     
  7. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    OK, I just spent an hour or so improving handling of repeat groups with the "must validate" stuff, found and fixed a number of potential problems:

    https://github.com/Fabrik/fabrik/commit/98ceb8849f817625fdcfbd68886586411aed242d

    Most of what I fixed was to do with removing groups. I noticed that we weren't accounting for repeats being removed, so if you had (say) 2 repeats, and the first one had been validated but the second one hadn't been validated, and you removed the second group ... the submit would stay disabled. I've fixed that, so we now correctly remove the any "must validate" elements form our internal check when a group is removed. So if you remove that second (unvalidated) group (and the first group has been validated), then the submit will become available.

    I also fixed an issue with repeats where you set "min repeat" to 0. Up till now, if you had a "must validate" element in a repeat group with min of 0 (such that the repeat doesn't show when you load the form), the submit button wouldn't get shown until you added the first repeat and validated it. Now, it'll work correctly, and if you never add a repeat, it won't affect submission.

    However ... none of what I've found so far would account for issues with 'calc' elements as the repeat count. I haven't actually tested that yet, as I needed to resolve those other issues first.

    I'll take a look at calcs now. But I'd recommend doing a github update, picking up these fixes, and see if they help.

    -- hugh
     
  8. mirceat

    mirceat Member

    Level: Community
    I've updated from github...thank you for your work, but it doesn't seems to works having a calc element, the submit button is still deactivated

    P.S: i think there is a problem with element validation in a repeat group when the fields are dynamically generated, the validation run only for the first field in group..
    For example, the group will repeat a field element 5 times in group. A notempty validation is triggered only for the first field and leave other four fields not validated so user can submit empty fields.
     
  9. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    What do you mean by "dynamically generated"?

    -- hugh
     
  10. mirceat

    mirceat Member

    Level: Community
    I mean there is only one field added by myself in repeated group, but based on value from "Repeat Num Element" in group settings, the field is "dynamically generated" several times, see attached image

    group settings
    Clipboard01.jpg

    Fields generated in form
    Clipboard02.jpg

    notempty validation (using Ajax), works fine for non ajax validation
    Clipboard05.jpg
     
    Last edited: Nov 14, 2018 at 8:31 AM
  11. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    Can you point me at an example. I can't replicate that.

    -- hugh
     

Share This Page