1

I have a few elements in my zend form that are sometime hidden via javascript.

I would like to disable their validations if they are hidden, so the form will be valid.

Any way to do it in the server side? or in the element settings?

Thanks.

Ran
  • 4,117
  • 4
  • 44
  • 70

2 Answers2

1

Depending on the situation, you could at the same time disable the hidden items. Thus they won't be posted and you could then use isValidPartial that only validates the fields that are send in parameter.

jhuet
  • 396
  • 2
  • 11
  • If you're using a `Zend_Form_Element` you could declare your hidden field like this `new Zend_Form_Element_Hidden('fieldName', array('disabled' => 'disabled'));`. But, again, if you disable them they won't be posted. – jhuet Sep 28 '11 at 07:34
0

I think you might need to remove the validators for the hidden fields (by calling clearValidators()) before calling isValid().

There is a similar question here: Zend form validation . You might get some inspiration from the answers.

Hope it helps,

Community
  • 1
  • 1
dinopmi
  • 2,683
  • 19
  • 24
  • it's a bit different since in that post the elements are completely removed. I'm just putting them in a div with display:none. Is there anyway to detect on the server side that they are hidden? – Ran Sep 27 '11 at 21:34