1. Fabrik 3.8.1 has been released. It is mostly bug fixes and feature enhancements, but does include two new plugins (push notifications, and the sequence element). As usual we strongly recommend testing the new release on a sandbox if your application is mission critical, and always do an Akeeba backup before updating.
    Dismiss Notice

Validation with condition on multipage

Discussion in 'Professional Support' started by procajlok, Mar 8, 2018.

  1. procajlok

    procajlok Member

    Level: Community
    Hello! :)
    In Fabrik 3.8 i have multipage form. On first page i have calc field with number (calc on save):
    PHP:
    $var = (int) '{zgloszenia___gr_iloscOs}';
    if (!empty ($var))
    {
    return "1";
    }
    On the same and next page (where i have repeat group) i have fields with validation where condition is
    PHP:
    return '{zgloszenia___gr_etap1}' == 1;
    and On:Edit; Must validate:Yes; Show valid icon:Yes.

    This i made for take mandatory fields on second (or third etc.... - depending on the calc field configuration) edit record by user.

    At the moment I see one problem:
    After save, when calc field == 1 validation run only when i try submit record (on last page) and form don't go to first page where i have this fields. I want to run validation on go to next page! :)
     
  2. troester

    troester Administrator Staff Member

    Level: Community
    "calc on save": do you mean you've set "only calc on save" = YES (default is NO)?
    If set to YES it will only calc on save.
    What are your exect settings?
     
  3. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    And is zgloszenia___gr_etap1 the calc element?

    -- hugh
     
  4. procajlok

    procajlok Member

    Level: Community
    Yes this is calc element. Calculation return is stored in the database and indicates whether the user has completed the fields within the first stage of filling the record. First stage is when user create record and fill two mandatory fields. Second stage is when user edit his record and '{zgloszenia___gr_etap1}' == 1 (like in notempty conditions) - then other fields are mandatory.

    I hope I write it clearly :)

    Yes, exactly.

    In fact - my problem is not PHP calc, store correct value and validation conditions. It will work, i think ;)
    My problem is that I would like the validation run before moving to the next page in multipage form :)
     
  5. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    I'm still unclear on what the problem is. Do you mean you want the validation run, or the calc to run in AJAX mode?

    Validations should always run on the page you are navigating away from.

    -- hugh
     
  6. procajlok

    procajlok Member

    Level: Community
  7. troester

    troester Administrator Staff Member

    Level: Community
    Is is not validating or is the condition not true?

    What happens if you clear the condition?

    What do you get if you do
    var_dump('{zgloszenia___gr_etap1}');exit;
    in the condition?
     
  8. procajlok

    procajlok Member

    Level: Community
    When condition is clear, validation run before we go to next page and the message is displayed correctly (red label, popup at the top of field).

    Nothing happens. I cant go to the next page. The form temporarily dims and stays on the same page without displaying any error.
    There is also no information about what is happening "in the background".

    If you were so kind, of course, you can log in and check what is happening on the system - DEV SDM. :)
     
  9. troester

    troester Administrator Staff Member

    Level: Community
    Hmm, I can't log in (...blocked or not activiated...)
    And which form/menu is it?
     
  10. procajlok

    procajlok Member

    Level: Community
    Your account is activated. I can login... Site: DEV SDM; login: fabrik :)

    Form: Zg?oszenie; Groups with validated fields: grupa3, grupa4 and Zg?oszenia- [zgloszenia_14_repeat] .
     
  11. troester

    troester Administrator Staff Member

    Level: Community
    I see
    SyntaxError: Unexpected token s in JSON (what was to expect with the var_dump)
    and
    string(0) ""
    in the network response.

    So your gr_etap1 is empty.
    You have set "only calc on save"=yes, so - it's only calculating on save (and not on page navigation).

    Remove the var_dump
    set "only calc on save"=no
    and maybe ajax calculation = yes
     
    Last edited: Mar 14, 2018

Share This Page