Quantcast
Channel: User easement - Stack Overflow
Viewing all articles
Browse latest Browse all 45

Zend Framework: Conditional validation

$
0
0

I need to set up some validation for a form field based on a value of another field.

For instance if profession is Doctor, then require specialty not to be blank ('') or none ('none').

$professionOptions = array(''      => 'Choose Profession','Dr.'   => 'Dr.','zzz'   => 'zzz','None'  => 'None'); $this->validator->field('profession')->inArray(array_keys($professionOptions)) ->message('Invalid profession.'); $specialtySelectOptions = array(''      => 'Choose Specialty','Heart' => 'Heart','Lungs' => 'Lungs','Feet'  => 'Feet','Nose'  => 'Nose');

How do i make the following dependent on the profession?

$this->validator->field('specialty')->inArray(array_keys($specialtySelectOptions))                                            ->message('Invalid salutation.');

Viewing all articles
Browse latest Browse all 45

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>