public function init() { $this->clearDecorators(); $this->addElementPrefixPath('Pas_Validate', 'Pas/Validate/', 'validate'); $this->addPrefixPath('Pas_Form_Element', 'Pas/Form/Element/', 'element'); $decorators = array(array('ViewHelper'), array('Description', array('placement' => 'append', 'class' => 'info')), array('Errors', array('placement' => 'append', 'class' => 'error', 'tag' => 'li')), array('Label', array('separator' => ' ', 'requiredSuffix' => ' *', 'class' => 'leftalign')), array('HtmlTag', array('tag' => 'li'))); $oldpassword = new Zend_Form_Element_Password('oldpassword'); $oldpassword->setLabel('Your old password: '******'RightPassword')->addFilters(array('StripTags', 'StringTrim')); $oldpassword->setDecorators($decorators); $password = new Zend_Form_Element_Password("password"); $password->setLabel("New password:"******"NotEmpty")->setRequired(true)->addFilters(array('StripTags', 'StringTrim'))->setDecorators($decorators)->addValidator('IdenticalField', false, array('password2', ' confirm password field')); // identical field validator with custom messages $hash = new Zend_Form_Element_Hash('csrf'); $hash->setValue($this->_config->form->salt)->removeDecorator('DtDdWrapper')->removeDecorator('HtmlTag')->removeDecorator('label')->setTimeout(60); $this->addElement($hash); $password2 = new Zend_Form_Element_Password("password2"); $password2->setLabel("Confirm password:"******"NotEmpty")->addFilters(array('StripTags', 'StringTrim'))->setRequired(true)->setDecorators($decorators); $submit = new Zend_Form_Element_Submit('submit'); $submit->clearDecorators(); $submit->addDecorators(array(array('ViewHelper'), array('HtmlTag', array('tag' => 'div', 'class' => 'submit')))); $submit->setAttrib('class', 'large')->setLabel('Change password'); $this->addElement($submit); $this->addElements(array($oldpassword, $password, $password2, $submit)); $this->addDisplayGroup(array('oldpassword', 'password', 'password2'), 'userdetails'); $this->addDecorator('FormElements')->addDecorator(array('ListWrapper' => 'HtmlTag'), array('tag' => 'div'))->addDecorator('FieldSet')->addDecorator('Form'); $this->userdetails->removeDecorator('DtDdWrapper'); $this->userdetails->removeDecorator('FieldSet'); $this->userdetails->addDecorator(array('DtDdWrapper' => 'HtmlTag'), array('tag' => 'ul')); $this->addDisplayGroup(array('submit'), 'submit'); $this->setLegend('Edit account details: '); }
public function init() { $required = true; $roles = new Roles(); $role_options = $roles->getRoles(); $inst = new Institutions(); $inst_options = $inst->getInsts(); $this->setAction($this->_actionUrl)->setMethod('post')->setAttrib('id', 'accountform'); $this->clearDecorators(); $this->addElementPrefixPath('Pas_Validate', 'Pas/Validate/', 'validate'); $this->addPrefixPath('Pas_Form_Element', 'Pas/Form/Element/', 'element'); $decorators = array(array('ViewHelper'), array('Description', array('placement' => 'append', 'class' => 'info')), array('Errors', array('placement' => 'prepend', 'class' => 'error', 'tag' => 'li')), array('Label', array('separator' => ' ', 'requiredSuffix' => ' *', 'class' => 'leftalign')), array('HtmlTag', array('tag' => 'li'))); $username = $this->addElement('text', 'username', array('label' => 'Username: '******'StripTags', 'StringTrim'))->setRequired(true); $firstName = $this->addElement('text', 'first_name', array('label' => 'First Name', 'size' => '30'))->first_name; $firstName->setRequired(true)->addFilters(array('StripTags', 'StringTrim'))->addValidator('Alnum', false, array('allowWhiteSpace' => true))->addErrorMessage('You must enter a firstname'); $firstName->setDecorators($decorators); $lastName = $this->addElement('text', 'last_name', array('label' => 'Last Name', 'size' => '30'))->last_name; $lastName->setRequired(true)->addFilters(array('StripTags', 'StringTrim'))->addValidator('Alnum', false, array('allowWhiteSpace' => true))->addErrorMessage('You must enter a surname'); $lastName->setDecorators($decorators); $fullname = $this->addElement('text', 'fullname', array('label' => 'Preferred Name: ', 'size' => '30'))->fullname; $fullname->setRequired(true)->addFilters(array('StripTags', 'StringTrim'))->addValidator('Alnum', false, array('allowWhiteSpace' => true))->addErrorMessage('You must enter your preferred name'); $fullname->setDecorators($decorators); $email = $this->addElement('text', 'email', array('label' => 'Email Address', 'size' => '30'))->email; $email->addValidator('EmailAddress')->addFilters(array('StripTags', 'StringTrim', 'StringToLower'))->setRequired(true)->addErrorMessage('Please enter a valid address!'); $email->setDecorators($decorators); $password = $this->addElement('password', 'password', array('label' => 'Change password: '******'size' => '30'))->password; $password->setRequired(false); $password->setDecorators($decorators); $institution = $this->addElement('select', 'institution', array('label' => 'Recording institution: '))->institution; $institution->setDecorators($decorators); $institution->addMultiOptions(array(NULL => NULL, 'Choose institution' => $inst_options)); $role = $this->addElement('select', 'role', array('label' => 'Site role: '))->role; $role->setDecorators($decorators); $role->addMultiOptions(array(NULL => NULL, 'Choose role' => $role_options)); $person = $this->addElement('text', 'person', array('label' => 'Personal details attached: '))->person; $person->setDecorators($decorators); $peopleID = $this->addElement('hidden', 'peopleID', array())->peopleID; $peopleID->setDecorators($decorators); $submit = new Zend_Form_Element_Submit('submit'); $submit->clearDecorators(); $submit->addDecorators(array(array('ViewHelper'), array('HtmlTag', array('tag' => 'div', 'class' => 'submit')))); $submit->setAttrib('class', 'large'); $this->addElement($submit); $hash = new Zend_Form_Element_Hash('csrf'); $hash->setValue($this->_config->form->salt)->removeDecorator('DtDdWrapper')->removeDecorator('HtmlTag')->removeDecorator('label')->setTimeout(60); $this->addElement($hash); $this->addDisplayGroup(array('username', 'first_name', 'last_name', 'fullname', 'email', 'institution', 'role', 'password', 'person', 'peopleID'), 'userdetails'); $this->addDecorator('FormElements')->addDecorator(array('ListWrapper' => 'HtmlTag'), array('tag' => 'div'))->addDecorator('FieldSet')->addDecorator('Form'); $this->userdetails->removeDecorator('DtDdWrapper'); $this->userdetails->removeDecorator('FieldSet'); $this->userdetails->addDecorator(array('DtDdWrapper' => 'HtmlTag'), array('tag' => 'ul')); $this->addDisplayGroup(array('submit'), 'submit'); $this->setLegend('Edit account details: '); }
public function init() { $required = true; $this->setAction($this->_actionUrl)->setMethod('post')->setAttrib('id', 'accountform'); $this->clearDecorators(); $this->addElementPrefixPath('Pas_Validate', 'Pas/Validate/', 'validate'); $this->addPrefixPath('Pas_Form_Element', 'Pas/Form/Element/', 'element'); $decorators = array(array('ViewHelper'), array('Description', array('placement' => 'append', 'class' => 'info')), array('Errors', array('placement' => 'prepend', 'class' => 'error', 'tag' => 'li')), array('Label', array('separator' => ' ', 'requiredSuffix' => ' *', 'class' => 'leftalign')), array('HtmlTag', array('tag' => 'li'))); $username = $this->addElement('text', 'username', array('label' => 'Username: '******'StripTags')->addFilter('StringTrim')->addValidator('StringLength', true, array('max' => 40))->setRequired(true); $username->getValidator('StringLength')->setMessage('Username is too long'); $password = $this->addElement('password', 'password', array('label' => 'Password'))->password; $password->addValidator('StringLength', true, array(6))->addValidator('Regex', true, array('/^(?=.*\\d)(?=.*[a-zA-Z]).{6,}$/'))->setRequired(true)->addErrorMessage('Please enter a valid password!'); $password->getValidator('StringLength')->setMessage('Password is too short'); $password->getValidator('Regex')->setMessage('Password does not contain letters and numbers'); $password->setDecorators($decorators); $firstName = $this->addElement('text', 'first_name', array('label' => 'First Name', 'size' => '30'))->first_name; $firstName->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addErrorMessage('You must enter a firstname'); $firstName->setDecorators($decorators); $lastName = $this->addElement('text', 'last_name', array('label' => 'Last Name', 'size' => '30'))->last_name; $lastName->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addErrorMessage('You must enter a surname'); $lastName->setDecorators($decorators); $fullname = $this->addElement('text', 'fullname', array('label' => 'Preferred Name: ', 'size' => '30'))->fullname; $fullname->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addErrorMessage('You must enter your preferred name'); $fullname->setDecorators($decorators); $email = $this->addElement('text', 'email', array('label' => 'Email Address', 'size' => '30'))->email; $email->addValidator('EmailAddress')->setRequired(true)->addFilter('StringToLower')->addFilter('StringTrim')->addFilter('StripTags')->addErrorMessage('Please enter a valid address!'); $email->setDecorators($decorators); $institution = $this->addElement('text', 'institution', array('label' => 'Recording institution: ', 'size' => '30'))->institution; $institution->setDecorators($decorators); $researchOutline = $this->addElement('textArea', 'research_outline', array('label' => 'Outline your research', 'rows' => 10, 'cols' => 40))->research_outline; $researchOutline->setRequired(false)->addFilter('HtmlBody')->addFilter('EmptyParagraph'); $reference = $this->addElement('text', 'reference', array('label' => 'Please provide a referee:', 'size' => '40'))->reference; $reference->setRequired(false)->addFilter('StripTags')->addFilter('StringTrim'); $reference->setDecorators($decorators); $referenceEmail = $this->addElement('text', 'reference_email', array('label' => 'Please provide an email address for your referee:', 'size' => '40'))->reference_email; $referenceEmail->setRequired(false)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('EmailAddress'); $referenceEmail->setDecorators($decorators); $submit = new Zend_Form_Element_Submit('submit'); $submit->setLabel('Set my account up on Beowulf'); $submit->clearDecorators(); $submit->addDecorators(array(array('ViewHelper'), array('HtmlTag', array('tag' => 'div', 'class' => 'submit')))); $submit->setAttrib('class', 'large'); $this->addElement($submit); $this->addDisplayGroup(array('username', 'password', 'first_name', 'last_name', 'fullname', 'email', 'institution', 'research_outline', 'reference', 'reference_email'), 'userdetails'); $this->addDecorator('FormElements')->addDecorator(array('ListWrapper' => 'HtmlTag'), array('tag' => 'div'))->addDecorator('FieldSet')->addDecorator('Form'); $this->userdetails->removeDecorator('DtDdWrapper'); $this->userdetails->removeDecorator('FieldSet'); $this->userdetails->addDecorator(array('DtDdWrapper' => 'HtmlTag'), array('tag' => 'ul')); $this->addDisplayGroup(array('submit'), 'submit'); $this->setLegend('Edit account details: '); }
public function init() { $required = true; $copyrights = new Copyrights(); $copy = $copyrights->getStyles(); $this->setAction($this->_actionUrl)->setMethod('post')->setAttrib('id', 'accountform'); $this->clearDecorators(); $decorators = array(array('ViewHelper'), array('Description', array('placement' => 'append', 'class' => 'info')), array('Errors', array('placement' => 'prepend', 'class' => 'error', 'tag' => 'li')), array('Label', array('separator' => ' ', 'requiredSuffix' => ' *', 'class' => 'leftalign')), array('HtmlTag', array('tag' => 'li'))); $username = $this->addElement('text', 'username', array('label' => 'Username:'******'StringTrim', 'StripTags')); $firstName = $this->addElement('text', 'first_name', array('label' => 'First Name: ', 'size' => '30'))->first_name; $firstName->setRequired(true)->addFilters(array('StringTrim', 'StripTags'))->addErrorMessage('You must enter a firstname'); $firstName->setDecorators($decorators); $lastName = $this->addElement('text', 'last_name', array('label' => 'Last Name: ', 'size' => '30'))->last_name; $lastName->setRequired(true)->addFilters(array('StringTrim', 'StripTags'))->addErrorMessage('You must enter a surname'); $lastName->setDecorators($decorators); $fullname = $this->addElement('text', 'fullname', array('label' => 'Preferred Name: ', 'size' => '30'))->fullname; $fullname->setRequired(true)->addFilters(array('StringTrim', 'StripTags'))->addErrorMessage('You must enter your preferred name'); $fullname->setDecorators($decorators); $email = $this->addElement('text', 'email', array('label' => 'Email Address', 'size' => '30'))->email; $email->addValidator('emailAddress')->setRequired(true)->addErrorMessage('Please enter a valid address!')->addFilters(array('StringTrim', 'StripTags', 'StringToLower'))->addValidator('EmailAddress', false, array('mx' => true)); $email->setDecorators($decorators); $password = $this->addElement('password', 'password', array('label' => 'Change password: '******'size' => '30'))->password; $password->addFilters(array('StringTrim', 'StripTags'))->setRequired(false); $password->setDecorators($decorators); $copyright = $this->addElement('select', 'copyright', array('label' => 'Default copyright: '))->copyright; $copyright->setRequired(TRUE); $copyright->addMultiOptions(array(NULL => 'Select a licence holder', 'Valid copyrights' => $copy))->addValidator('InArray', false, array(array_keys($copy)))->setDecorators($decorators); $submit = new Zend_Form_Element_Submit('submit'); $submit->setLabel('Save details'); $submit->clearDecorators(); $submit->addDecorators(array(array('ViewHelper'), array('HtmlTag', array('tag' => 'div', 'class' => 'submit')))); $submit->setAttrib('class', 'large'); $this->addElement($submit); $this->addDisplayGroup(array('username', 'first_name', 'last_name', 'fullname', 'email', 'password', 'copyright'), 'userdetails'); $this->addDecorator('FormElements')->addDecorator(array('ListWrapper' => 'HtmlTag'), array('tag' => 'div'))->addDecorator('FieldSet')->addDecorator('Form'); $this->setLegend('Edit your account and profile details: '); $this->userdetails->removeDecorator('DtDdWrapper'); $this->userdetails->removeDecorator('HtmlTag'); $this->userdetails->removeDecorator('FieldSet'); $this->userdetails->addDecorator(array('DtDdWrapper' => 'HtmlTag'), array('tag' => 'ul')); $this->addDisplayGroup(array('submit'), 'submit'); }
public function __construct($options = null) { parent::__construct($options); $this->setAttrib('accept-charset', 'UTF-8'); $this->clearDecorators(); $decorators = array(array('ViewHelper'), array('Description', array('placement' => 'append', 'class' => 'info')), array('Errors', array('placement' => 'prepend', 'class' => 'error', 'tag' => 'li')), array('Label', array('separator' => ' ', 'class' => 'leftalign')), array('HtmlTag', array('tag' => 'div'))); $this->setName('workflow'); $id = new Zend_Form_Element_Hidden('id'); $id->removeDecorator('label'); $wfstage = new Zend_Form_Element_Radio('wfstage'); $wfstage->setRequired(false)->addMultiOptions(array('1' => 'Quarantine', '2' => 'Review', '4' => 'Validation', '3' => 'Published'))->addFilter('StripTags')->addFilter('StringTrim')->setDecorators($decorators); //Submit button $submit = new Zend_Form_Element_Submit('submit'); $submit->setAttrib('id', 'submitbutton'); $submit->clearDecorators(); $submit->addDecorators(array(array('ViewHelper'), array('HtmlTag', array('tag' => 'div', 'class' => 'submit')))); $this->setLegend('Workflow status'); $this->addDecorator('FormElements')->addDecorator('Form')->addDecorator('Fieldset'); $this->addElements(array($id, $wfstage, $submit)); }
public function addSubmitElement() { require_once 'Zend/Form/Element/Submit.php'; $submit = new Zend_Form_Element_Submit($this->getSubmitParam(), $this->getTranslator()->translate('accountLoginFormSubmitButton')); $submit->clearDecorators()->addDecorator('viewHelper'); $this->addElement($submit); return $this; }