• 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 condition OR

enzo2016

Member
Hi,
a form includes two elements with validation notempty. I would need that at least one of them is not empty. So if one (or both of them) is full then is ok, but if both of them are empty, then the validation should avoid that.
I wrote the following code into the condition box for both of them:

Code:
return '{table___element}' == 2 || '{table___element}' == 1;

I tested it, but if I don't fill both of elements, then no validation is shown. How can I solve?

Thanks,
Enzo
 
I would just do it with a PHP validation on both elements, that does ...

return !(empty($formModel->formData['table___element1'] && empty($formModel->formData['table___element2']);

-- hugh
 
Thanks for the code. If I don't fill both of the two elements, then the following error appears: 0 syntax error, unexpected ';'

By deleting the ; (semicolon) from the code, it appears: 0 syntax error, unexpected end of file.


-- Enzo
 
Ooops, typo ...

Code:
return !(empty($formModel->formData['table___element1']) && empty($formModel->formData['table___element2']));

That's the problem with writing code of the top of one's head with lots of brackets, easy to lose count.

-- hugh
 
Thanks. Both of the elements have a php validation. If one of these elements has for example also a isemail validation, how could this further validation be activated only if this element was filled?
Example: the form includes 'element 1' and 'element 2' with this php validation. If the user fills only element 1, but element 2 has also an isemail validation. How could this validation (of element 2) be activated only if element 2 is filled?

Thanks,

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

Thank you.

Members online

Back
Top