• Hello Fabrik Community

    Fabrik is now in the hands of the development team that brought you Fabrik for Joomla 4. We have recently transitioned the Fabrik site over to a new server and are busy trying to clean it up. We have upgraded the site to Joomla 4 and are running the latest version of Fabrik 4. We have also upgraded the Xenforo forum software to the latest version. Many of the widgets you might have been used to on the forum are no longer operational, many abandoned by the developers. We hope to bring back some of the important ones as we have time.

    Exciting times to be sure.

    The Fabrik 4.0 Official release is now available. In addition, the Fabrik codebase is now available in a public repository. See the notices about these in the announcements section

    We wish to shout out a very big Thank You to all of you who have made donations. They have really helped. But we can always use more...wink..wink..

    Also a big Thank You to those of you who have been assisting others in the forum. This takes a very big burden off of us as we work on bugs, the website and the future of Fabrik.

validation with two elements, one non-empty

MILORD65

Member
Hello,

I have two ?l?ments on the same form and I want them to be validated only if at least one of them or both is not empty.
I think it is necessary to use the php validation plugin but I don't find the code to put in condition and in php code.
Thank for your help

JP
 
Well, are you talking about using this as the "condition" (which determines if the validation itself should be run), or as the validation itself?

If it's the validation itself, then don't put it in the Condition, put it in the PHP code box.

-- hugh
 
Thank you for your reply.
The problem is that if I put this code in the php code box, the validation fails for both items. If I put it in the condition box nothing happens. What I am trying to do is a validation if at least one of the two elements is filled or both.
Validation must fail if both elements (A and B) are empty.
I think this is the same as in the post: http://www.fabrikar.com/forums/index.php?threads/validation-with-condition-or.47055/#post-244942
I had thought of using the notempty plugin but the post that I found on the forum advises rather the plugin PHP validation.

JP
 
Thank for your reply.
By "the validation fails for both items", I mean that the text "validation failed" appears in red under the two elements and the text "Some parts of your form have not been filled correctly" on top of the form.
 
To try to better explain my problem:
If in the php validation plugin I put only in PHP code for my two elements A and B:
PHP:
return $data != '';
the validation is done systematically but separately and the message "Some parts of your form have not been properly filled in" is displayed if one of the elements is empty.
If in addition I put in "condition" of the php validation pluginfor both elements:
PHP:
return !(empty($formModel->formData['mytable ___ elementA']) && empty($formModel->formData['mytable ___ elementB']));
registration does not fail and no message "Some parts of your form have not been properly filled in" if both elements are empty.

JP
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top