'Select a School') + $this->dataObj->getSchool4Select(); $form->addElement( 'select', 'idSchool', array('label' => 'School Name', 'required' => true, 'multiOptions' => $schools) ); $form->addElement('text', 'name', array('label' => 'Contact Name', 'required' => true)); $form->addElement('text', 'position', array('label' => 'Position', 'required' => true)); $form->addElement('phone', 'phone', array('label' => 'Phone Number')); $form->addElement( 'text', 'email', array('label' => 'Email', 'required' => true, 'description' => '(will be used as a login)') ); $form->email->addValidator('EmailAddress', true , array( 'messages' => array( Zend_Validate_EmailAddress::INVALID => 'Email Address is wrong', Zend_Validate_EmailAddress::INVALID_FORMAT => 'Email Address is wrong', ), 'domain' => false, )); $emailValidator = new Qs_Validate_Unique($this->dataObj->table, 'email', $this->dataObj->getPrimaryKey()); $emailValidator->setMessage('Email must be unique', Qs_Validate_Unique::NOT_UNIQUE); $form->email->addValidator($emailValidator); $form->addElement('password', 'password', array('label' => 'Password')); $form->addElement('password', 'confirmPassword', array('label' => 'Confirm Password')); $form->password->addValidator('ConfirmPassword', false, array('confirmPassword')); return $this; } protected function _getDefaultLinks() { $links = parent::_getDefaultLinks(); $idSchool = $this->dataObj->getFilter('idSchool'); if ($idSchool) { $links['new'] = array( 'title' => $links['new'], 'url' => $this->url(array('action' => 'new')) . '&idSchool=' . $idSchool, ); } return $links; } protected function _bindFilterFields($form) { parent::_bindFilterFields($form); $schools = array('' => 'All Schools') + $this->dataObj->getSchool4Select(); $form->addElement( 'select', 'idSchool', array('label' => 'School', 'onchange' => 'this.form.submit();', 'multiOptions' => $schools) ); return $this; } public function getFormDefaults($field = false) { $this->_formDefaults['idSchool'] = Qs_Request::getGetValue('idSchool'); return Qs_Array::get($this->_formDefaults, $field); } }