Element validation based on other element

jo-ka

Member
Hello.

If I have a form where one of the fields is active (with yes/no element) and then I have another field, lest's call it wire transfer, based on yes/no element, is there a way to have a validation on the form that prevents saving the form, when the wire transfer is set to yes and active is set to no?

In order words, it doesn't make sense to set one field to yes, if the other is set to no. This is to avoid the end user to make the mistake of charge the monthly subscription, when the customer is not active.

Plus:

I also have a list plugin that changes the state of wire transfer to yes (this to avoid editing the customer record and set wire transfer easily). Is there also a way to have the same behaviour, this is, prevent the user to set wire transfer to yes, if the field active is set to no?

Or even better...

On the list, have a custom.css that hides the wire transfer list button, if the active value is set to no?

Thanks in advance.
 
Dear juuser, thanks for your reply.
You're right, this is the same thing we've discussed on this topic. Many thanks for reminding me.
For the second issue, doesn't the same method work like discussed here?
https://fabrikar.com/forums/index.p...e_col-based-on-field-value.51768/#post-270221

About the solution to validation, I was able to do it on the form, by setting the validation on the element, more or less as you've suggested, but with a small change:

First, I've added a condition for validation, because the validation will only run if the wire transfer is set to Yes (1).

Code:
return ($data == "1");

Then, I've changed the code, in order to validate the element value on the form, removing the _raw. Also, I had to change the $myyesno value to 1.

Code:
$myyesno = JRequest::getVar('mytable___yesno_element');
return ($myyesno == "1" && $data == "1");

Your suggestion was very good. Thanks again.
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top