Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- CREATE TABLE `villains` (
- `id` int(11) NOT NULL AUTO_INCREMENT,
- `name` varchar(255) NOT NULL,
- `mode` varchar(255) NOT NULL,
- PRIMARY KEY (`id`)
- ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;
- --
- -- Dumping data for table `villains`
- --
- INSERT INTO `villains` VALUES(1, 'Joker', 'employer');
- INSERT INTO `villains` VALUES(2, 'Kingpin', '');
- */
- class FormVillain extends Zend_Form
- {
- public function init()
- {
- $id = new Zend_Form_Element_Select("id");
- $id->setRegisterInArrayValidator(false)->addValidator(
- new Zend_Validate_Db_RecordExists(
- array(
- 'table' => 'villains',
- 'field' => 'id',
- 'exclude' => "mode != 'employer'"
- )
- ));
- $this->addElement($id);
- }
- }
- if (!empty($_POST))
- {
- $form = new FormVillain();
- if ($form->isValid($_POST))
- {
- $values = $form->getValues();
- var_dump($values);
- }
- else
- var_dump($form->getMessages());
- }
- ?>
- <form method='post'>
- <select name='id'>
- <option value='1'>Joker</option>
- <option value='2'>Kingpin</option>
- <option value='3'>Poison Ivy</option>
- </select>
- <input type='submit' value='submit'/>
- </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement