where should the 'not empty' validation error be displayed?

rw1

Moderator
hello,

i have a form module, loading in a pop up modal window for a multipage form.

so there are about 5 pages with about 4 fields on each page.

i started the process of adding validations to the fields.

the first field is a dropdown field.

i added the validation 'not empty' to the field and if i click 'submit' without selecting anything, the modal window closes (or more precisely the whole page is reloading), then when i open the modal window again, the field label is red with a '!' icon next to it, with the error message visible when hovering over the '!'.

so i guess, issue one is how to stop the modal window from closing when clicking submit, and issue two is - is that how the 'not empty' validation is meant to appear?

thanks!
 
perhaps the 'easiest' way to solve this would be if the 'submit' buttom was greyed out and unclickable as was mentioned here as the validation does not let you move forward a page without the required field being filled in (which is good). and if the 'submit' button wasn't available then this undesired behaviour wouldn't be possible.
 
yep, done and dusted, the greyed out 'submit' button is back in business and solves the issue of being able to click 'submit' at any time during a multi page form in a modal window scenario - which would cause the whole page to reload. now, you cannot click 'submit' unless you are on the last page and with validation enabled, you cannot move forwards or backwards a page without filling in the required fields. awesome!
 
hmm, is there anyway to apply a 'notempty' validation to a dropdown element?

the form ignores this validation because i guess, technically speaking, it is not empty as the first VALUE is 0 with the LABEL select.

i tried making the value empty but then i could not save the element.

hmmm.
 
i've never done it before, or understand what it means, but perhaps i could do a regex validation and say "is not equal to '0'" - the VALUE of the select label?

edit: or maybe a php comparison operator? (again not sure what that is or how to implement it).

edit 2: just guessing, but i tried to add this to the element's validation (type: php), in the 'php code' area:
Code:
<?phpif $data != "0";?>
but it stopped the user from being able to navigate between the pages.

anyone have any ideas on how to validate a dropdown field? ie require that a value be selected?
 
For validation on drop down element, put "0" (zero) as value for the "please choose" option, then use a "isnot" validation with "0" as the "isnot" value.
 
thanks very much for this jfquestiaux, i didn't know there were so many validations avalilable - cool!

but, i just installed the 'is not' validation (via manager > discover > install), enabled it, and added it to a dropdown element, and when i load the site i get the error:

Fatal error: Class 'plgFabrik_ValidationruleIsnot' not found in /home/***/public_html/components/com_fabrik/models/element.php on line 1680

first i had added 0 as the 'Is Not' value, and then i tried "0" and i have the same result for both.
 
I think something should have happened when you installed it because I am using this validation on a new site (with Git 124) and I don't have the error.
 
ah, default access level of plugin was set to 'registered' and it is a 'public' form.

that cleared up the error, thanks for testing.

it is working sporadically for me now, sometimes the validation comes up and sometimes i can navigate to the next page. i have cleared browser cache etc.

so i have:

====value=====++++label++++
=====0=======+++select++++
=====1=======+++label1++++

etc with the 0 value checked as default

i have a validation message 'please select a value' and the 'Is Not' field is 0 (and i have also tried "0").

is that the same settings that you have set up?

thanks!
 
Actually, I have not checked the "select" as default. it is just at the top of teh list and the one that shows.
Settings are like attachment.
 

Attachments

  • 2012-03-14 17.34.00.png
    2012-03-14 17.34.00.png
    19.8 KB · Views: 205
hmm, thanks for your reply, yes i tried without 'Default' checked as well, might have to resume troubleshooting this tomorrow, thanks for your help though!
 
hmm, i'm troubleshooting this again and i just replaced all my custom error message css with default templates and it is still not validating consistently. have cleared cache and closed browser and have latest git update.

so the element is a dropdown with a 'isnot' validation set to 'Is Not' 0, with 'please select' option having a VALUE of 0. any ideas anyone?

thanks!
 
i've just switched back to applying the complete 'default' template for the form so i am sure it is not a css issue and i am getting the same results.

what is interesting is that the 'alert' image shows for the other fields when trying to move forward a page, but not the dropdown even though it has a 'Is Not' 0 validation applied to it.

please see attached.

edit: also firebug shows me that the error class is not being applied to the dropdown - see below where a field comes directly after the dropdown and does have the fabrik error class applies to it:
Code:
<li class="fabrikElementContainer dropdown fabrikDataEmpty" style="clear:both;width:100%;">
<li class="fabrikElementContainer field fabrikDataEmpty fabrikError" style="clear:both;width:100%;">
 

Attachments

  • not_validating_dropdown.PNG
    not_validating_dropdown.PNG
    3.3 KB · Views: 139
can you try setting the option with the value of '0' to a different value to see if that effects something? I'm wondering if the condition isn't too loose and its seeing "0" and "" as the same thing
 
hi rob,

unfortunately no, i tried setting 'Is Not" 1 and made the value of 'select' 1 and it is still not validating.
 
Are you sure you switched back to the default template? If you access your form from a menu link, the template chosen in the options of the menu overrides the setting you set in the form layout tab.
 
hi jfquestiaux,

thanks for the idea.

yes they are very different templates ie the one i use looks very different. and i was making the template switch from the form module actually (because it is a form displayed in a form module that opens in a pop up modal).
 
OK. I think that form in modules have sometimes funky behaviors.
Test your form outside the module to check whether this is the problem.
 
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top