lcollong
FabriKant d'applications web
Hi,
I've a custom form template with a very simple mod in the file "default_group.php" :
It works as it should : not displaying the element "enf_photo" if the session var "dispPhoto" is set to false.
But if my form failed to validate, it is displayed back to the user with the unwanted element.
This happens only if I publish a php form plugin onBeforeLoad set to "front-end" and "new form only" (see snapshot). Even if the php does nothing or very few ("echo 'hello';" or "return true;"). As soon as I unpublish the plugin, everything is working fine : the element does not show and if the validation fail, the form is displayed back with the right errors messages and without the "enf_photo" as expected.
It's pretty easy to reproduce. I've also tried to set a specific class rather than use "$element->hidden" but the result is the same, the class does not show up in case the form is displayed back after a failed validation.
The purpose of the plugin is to prevent the form to be displayed if a quota limit is reached. I Have written a function which return true if it's ok or redirect the user to a specific place in case of quota reached.
It has nothing to see with the fact to display or not the "enf_photo" element. But one is disturbing the other.
Any suggestion ?
I've a custom form template with a very simple mod in the file "default_group.php" :
PHP:
foreach ($this->elements as $element) :
$this->element = $element;
if ((strpos($element->id,'enf_photo') && !JFactory::getSession()->get('dispPhoto', '0' ))) $element->hidden = true;
It works as it should : not displaying the element "enf_photo" if the session var "dispPhoto" is set to false.
But if my form failed to validate, it is displayed back to the user with the unwanted element.
This happens only if I publish a php form plugin onBeforeLoad set to "front-end" and "new form only" (see snapshot). Even if the php does nothing or very few ("echo 'hello';" or "return true;"). As soon as I unpublish the plugin, everything is working fine : the element does not show and if the validation fail, the form is displayed back with the right errors messages and without the "enf_photo" as expected.
It's pretty easy to reproduce. I've also tried to set a specific class rather than use "$element->hidden" but the result is the same, the class does not show up in case the form is displayed back after a failed validation.
The purpose of the plugin is to prevent the form to be displayed if a quota limit is reached. I Have written a function which return true if it's ok or redirect the user to a specific place in case of quota reached.
It has nothing to see with the fact to display or not the "enf_photo" element. But one is disturbing the other.
Any suggestion ?