Validation and hiding (solved)

Status
Not open for further replies.

zebrafilm

Member
One page with 5 elements. They are all mandatory and all cascading drop downs.
So you need to see the first to see the second loading with content etc. (Ajax)

Now my client wants suddenly an op option "unknown" which should disable the 4 remaining elements because they are no longer relevant. I have added the 'Unknown' in the first dropdown list.

Normally I create a subgroup and hide it with JS in the first element.
But when the subgroup fields are hidden, I can't continue. They are still mandatory.
Since my JS skills are limited to the boxes presented, I can hide and show and thats it.
Would disabling fields let me pass them?

What is the best practice to get this working?

Bastiaan
 
You could add a condition to your validations, e.g.
return '{your-dropdown}' != 'unknown';
 
I have a problem related to this but the case is slightly different. I have a checkbox which controls the hide/show of several groups. I need validations of the elements in those groups which are hidden/shown conditionally based on the checkbox element. If I insert return '{your-element}' == 'Value'; as a condition of those elements the validation works if I only check one option in the check box. If I choose more checkboxes it won't validate the elements.

To illustrate with an example:
  • Field name: Checkbox
  • Alternatives: Group 1, Group 2, Group 3, Group 4
  • In the elements in Group 1 I have return '{table__checkbox' == 'Group 1'; as a condition
  • In the elements in Group 2 I have return '{table__checkbox}' == 'Group 2'; as a condition
  • ....
If I in the checkbox only choose Group 1 or only Group 2 it works as it should but it doesn't validate the elements if I e.g. choose Group 1 AND Group 2 at the same time.

How can I write this condition? Thank you for your help.
 
Quote:
You could add a condition to your validations, e.g.
return '{your-dropdown}' != 'unknown';
End quote

OK I have entered this in the condition field for the first cascading dropdown, see pic below but it does not make a difference.

Screen Shot 2014-05-08 at 15.08.59.png

It still wants to be validated.
(nice function btw that override, did not see it yet)

(Latest Gitub with J3.3)
 
jh - can you start your own thread? We try and avoid Hydra Headed Threads with multiple issues. Quick answer, I think for multiple selections, the placeholder will be JSON data, which you'll have to run through json_decode(), which would give you an array of selected options. Easiest way to tell is to dump the data, like var_dump('{table___element}');exit; and see what it looks like. If it's of the form {"something":"foo","something_else":"bar"}, that's JSON.

@zebra - same advise there. Dump your data, to see what you are actually getting from the placeholder.

$your_value = '{table___element}';
var_dump($your_value);exit;

... and see what it looks like.

-- hugh
 
Did something similar by creating a test (calc)element with return '{truck1___truck_merk}';
It shows the same value I am using for the validation. No unexpected answers there.

Where would you put your dump statement normally?
 
Status
Not open for further replies.
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top