addElement('text', 'title', array('label' => 'Job Title', 'required' => true)); $this->_addCompanyAddressElements(); $this->_addJobDescriptionElements(); $this->_addContactElements(); $this->addElement( 'text', 'companyWebsite', array( 'label' => 'Company Website', 'validators' => array('Url'), 'description' => 'Example: http://www.adaptainc.com', ) ); return parent::_initElements(); } protected function _addContactElements() { $this->addElement('text', 'contactName', array('label' => 'Contact Name')); $this->addElement('phone', 'contactPhone', array('label' => 'Contact Phone')); $this->addElement( 'text', 'contactEmail', array('label' => 'Contact Email', 'validators' => array('EmailAddress')) ); return $this; } protected function _addJobDescriptionElements() { $this->addElement( 'text', 'url', array( 'label' => 'Job URL', 'validators' => array('Url'), 'description' => 'Example: http://www.adaptainc.com', ) ); $this->addElement( 'textarea', 'brief', array( 'label' => 'Brief Description', 'required' => true, ) ); $length = (int) $this->getConfig('briefLength'); if ($length) { $lengthValidator = new \Zend_Validate_StringLength(0, $length); $lengthValidator->setMessage( "Brief Description is less than %min% characters long", \Zend_Validate_StringLength::TOO_SHORT ); $lengthValidator->setMessage( "Brief Description is more than %max% characters long", \Zend_Validate_StringLength::TOO_LONG ); $this->getElement('brief')->setAttrib('maxlength', $length); $this->getElement('brief')->addValidator($lengthValidator); $description = 'Text space is limited to ' . $length . ' characters'; $this->getElement('brief')->setOptions(array('description' => $description)); } $this->addElement( 'htmlEditor', 'description', array('label' => 'Job Description', 'required' => true, 'hasMsWordNote' => true) ); $this->addElement( 'htmlEditor', 'apply', array('label' => 'How to Apply', 'required' => true, 'hasMsWordNote' => true) ); return $this; } protected function _addCompanyAddressElements() { $this->addElement('text', 'company', array('label' => 'Company Name', 'required' => true)); $this->addElement('text', 'address', array('label' => 'Address', 'required' => true)); $this->addElement('text', 'city', array('label' => 'City', 'required' => true)); $this->addElement( 'select', 'state', array( 'label' => 'State', 'required' => true, 'multiOptions' => array('' => 'Select One') + $this->_getStates4Select() ) ); $validator = new \Zend_Validate_PostCode(new \Zend_Locale('en_US')); $validator->setMessage('Zip Code is in wrong format', \Zend_Validate_PostCode::NO_MATCH); $this->addElement( 'text', 'zip', array( 'label' => 'Zip', 'required' => true, 'validators' => array($validator), 'description' => 'Allowed characters: 0-9, \'-\'', ) ); $this->addDisplayGroup( array('city', 'state', 'zip'), 'cityStateZipGroup' ); return $this; } protected function _getStates4Select() { return (new \Qs_Db_Table('DState'))->get4Select(); } }