public function init() { // Set the method for the display form to POST $this->setMethod('post'); $this->setAttribs(array('class' => 'form-horizontal')); $decoratorField = new My_Decorator_FieldLogin(); $elements = array(); // Add email field $input = new Zend_Form_Element_Text('email', array('required' => true, 'label' => 'Email Address:', 'id' => 'email', 'placeholder' => 'Your email..', 'class' => 'form-control', 'type' => 'email')); $validator = new Zend_Validate_EmailAddress(); $validator->setOptions(array('domain' => false)); $input->addValidators(array($validator, new Zend_Validate_NotEmpty())); $input->addDecorator($decoratorField); $elements[] = $input; // Add password field $input = new Zend_Form_Element_Password('password', array('required' => true, 'label' => 'Password:'******'id' => 'password', 'class' => 'form-control', 'placeholder' => 'Your password..')); $input->addValidators(array(new Zend_Validate_NotEmpty())); $input->addDecorator($decoratorField); $elements[] = $input; // Add checkbox field $input = new Zend_Form_Element_Checkbox('rememberMe', array('label' => 'Remember me', 'id' => 'rememberMe', 'class' => 'checkbox', 'type' => 'checkbox')); $decoratorCheckBox = new My_Decorator_CheckBox(); $input->addDecorator($decoratorCheckBox); $elements[] = $input; $input = new Zend_Form_Element('resetpass', array('label' => 'Reset your password', 'id' => 'resetpass', 'class' => 'form-control', 'value' => 'resetpass')); $input->addDecorator(new My_Decorator_AnchoraForm()); $elements[] = $input; //Add Submit button $input = new Zend_Form_Element_Submit('submit', array('Label' => '', 'class' => 'btn btn-default', 'value' => 'Login')); $input->addDecorator($decoratorField); $elements[] = $input; $this->addElements($elements); $this->addDisplayGroup(array('email', 'password', 'resetpass', 'rememberMe', 'submit'), 'displgrp', array('decorators' => array('FormElements', 'Fieldset'))); }
private function getFormLogin() { $form = new Zend_Form(array('disableLoadDefaultDecorators' => true)); $email = new Zend_Form_Element_Text('login', array('disableLoadDefaultDecorators' => true)); $email->addDecorator('ViewHelper'); $email->addDecorator('Errors'); $email->setRequired(true); $email->setAttrib('class', 'form-control'); $email->setAttrib('placeholder', 'Login'); $email->setAttrib('required', 'required'); $email->setAttrib('autofocus', 'autofocus'); $password = new Zend_Form_Element_Password('password', array('disableLoadDefaultDecorators' => true)); $password->addDecorator('ViewHelper'); $password->addDecorator('Errors'); $password->setRequired(true); $password->setAttrib('class', 'form-control'); $password->setAttrib('placeholder', 'Hasło'); $password->setAttrib('required', 'required'); $password->setAttrib('autofocus', 'autofocus'); $submit = new Zend_Form_Element_Submit('submit', array('disableLoadDefaultDecorators' => true)); $submit->setAttrib('class', 'btn btn-lg btn-primary btn-block'); $submit->setOptions(array('label' => 'Zaloguj')); $submit->addDecorator('ViewHelper')->addDecorator('Errors'); $form->addElement($email)->addElement($password)->addElement($submit); return $form; }
protected function setButton() { $submit = new Zend_Form_Element_Submit("submit", array("label" => "Salvar")); $submit->removeDecorator('DtDdWrapper'); $submit->addDecorator(array("opentd" => 'HtmlTag'), array('class' => 'form_control_left', 'tag' => 'td')); $submit->addDecorator(array("opentr" => 'HtmlTag'), array('tag' => 'tr', 'openOnly' => true, 'placement' => Zend_Form_Decorator_Abstract::PREPEND)); $submit->setOrder(100); $this->addElement($submit); $back = new Zend_Form_Element_Button("cancel", array("label" => "Cancelar")); $back->setAttrib("onclick", "location.href='javascript:history.back();'"); $back->removeDecorator('DtDdWrapper'); $back->addDecorator(array("closetd" => 'HtmlTag'), array('class' => 'form_control_right', 'tag' => 'td')); $back->addDecorator(array("closetr" => 'HtmlTag'), array('tag' => 'tr', 'closeOnly' => true, 'placement' => Zend_Form_Decorator_Abstract::APPEND)); $back->setOrder(101); $this->addElement($back); }
public function init() { // Set the method for the display form to POST $this->setMethod('post'); $this->setAttribs(array('class' => 'form-horizontal')); $decoratorField = new My_Decorator_FieldLogin(); $elements = array(); // Add oldpass field $input = new Zend_Form_Element_Password('oldpassword', array('required' => true, 'label' => 'Old Password:'******'id' => 'oldpassword', 'placeholder' => 'Old pass..', 'class' => 'form-control')); $input->addValidator(new Zend_Validate_NotEmpty()); $input->addDecorator($decoratorField); $elements[] = $input; // Add newpass1 field $input = new Zend_Form_Element_Password('newpassword1', array('required' => true, 'label' => 'New Password:'******'id' => 'newpassword1', 'class' => 'form-control', 'placeholder' => 'Your password..')); $input->addValidators(array(new Zend_Validate_Alnum(), new Zend_Validate_StringLength(array('min' => 8)), new Zend_Validate_NotEmpty())); $input->addDecorator($decoratorField); $elements[] = $input; // Add newpass2 field $input = new Zend_Form_Element_Password('newpassword2', array('required' => true, 'label' => 'New Password Again:', 'id' => 'newpassword2', 'class' => 'form-control', 'placeholder' => 'Your password again..', 'validators' => array(array('identical', false, array('token' => 'newpassword1'))))); $input->addDecorator($decoratorField); $elements[] = $input; //Add Submit button $input = new Zend_Form_Element_Submit('submit', array('Label' => '', 'class' => 'btn btn-default', 'value' => 'Update')); $input->addDecorator($decoratorField); $elements[] = $input; $this->addElements($elements); $this->addDisplayGroup(array('oldpassword', 'newpassword1', 'newpassword2', 'submit'), 'displgrp', array('decorators' => array('FormElements'))); }
public function init() { $this->setMethod('post'); $decoratorField = new My_Decorator_Field(); $elements = array(); //Add id hidden field $input = new Zend_Form_Element_Hidden('product_id'); $min = new Zend_Validate_GreaterThan(self::MIN); $input->addValidators(array(new Zend_Validate_Digits(), $min, new Zend_Validate_NotEmpty())); $elements[] = $input; //Add Submit button $input = new Zend_Form_Element_Submit('submit', array('Label' => '', 'class' => 'btn btn-danger', 'value' => 'Delete')); $elements[] = $input; $input->addDecorator($decoratorField); $this->addElements($elements); }
public function init() { // Set the method for the display form to POST $this->setMethod('post'); $this->setAttribs(array('class' => 'form-horizontal')); $decoratorField = new My_Decorator_Field(); $elements = array(); // Add name field $input = new Zend_Form_Element_Text('host', array('required' => true, 'label' => 'SMTP Host:', 'id' => 'host', 'placeholder' => 'Type something..', 'class' => 'form-control', 'value' => 'smtp.gmail.com')); $input->addValidators(array(new Zend_Validate_NotEmpty())); $input->addDecorator($decoratorField); $elements[] = $input; // Add category field $select = new Zend_Form_Element_Select('stype', array('required' => true, 'label' => 'Security:', 'id' => 'stype', 'class' => 'form-control')); $select->addMultiOption('TLS', 'TLS'); $select->addMultiOption('SSH', 'SSH'); $select->setValue('TLS'); $select->addDecorator($decoratorField); $elements[] = $select; // Add Price field $input = new Zend_Form_Element_Text('port', array('required' => true, 'label' => 'Port:', 'id' => 'port', 'placeholder' => 'Type something..', 'class' => 'form-control', 'min' => 0, 'step' => '1', 'type' => 'number', 'value' => '587')); $min = new Zend_Validate_GreaterThan(0); $input->addValidators(array(new Zend_Validate_Digits(), $min, new Zend_Validate_NotEmpty())); $input->addDecorator($decoratorField); $elements[] = $input; $input = new Zend_Form_Element_Text('email', array('required' => true, 'label' => 'SMTP Email Address:', 'id' => 'email', 'placeholder' => 'Your email..', 'class' => 'form-control', 'type' => 'email', 'value' => '*****@*****.**')); $input->addValidators(array(new Zend_Validate_EmailAddress(), new Zend_Validate_NotEmpty())); $input->addDecorator($decoratorField); $elements[] = $input; // Add category field $input = new Zend_Form_Element_Password('password1', array('required' => true, 'label' => 'Password:'******'id' => 'password1', 'class' => 'form-control', 'placeholder' => 'Your SMTP password..')); $input->addValidators(array(new Zend_Validate_NotEmpty())); $input->addDecorator($decoratorField); $elements[] = $input; // Add category field $input = new Zend_Form_Element_Password('password2', array('required' => true, 'label' => 'Password Again:', 'id' => 'password2', 'class' => 'form-control', 'placeholder' => 'Your SMTP password again..', 'validators' => array(array('identical', false, array('token' => 'password1'))))); $input->addDecorator($decoratorField); $elements[] = $input; //Add Submit button $input = new Zend_Form_Element_Submit('submit', array('Label' => ' ', 'class' => 'btn btn-info', 'value' => 'Add New Configuration')); $input->addDecorator($decoratorField); $elements[] = $input; $this->addElements($elements); $this->addDisplayGroup(array('host', 'stype', 'port', 'email', 'password1', 'password2', 'submit'), 'displgrp', array('legend' => 'Add Products', 'decorators' => array('FormElements', 'Fieldset'))); return $this; }
public function init() { // Set the method for the display form to POST $this->setMethod('post'); $this->setAttribs(array('class' => 'form-horizontal')); $decoratorField = new My_Decorator_FieldLogin(); $elements = array(); // Add email field $input = new Zend_Form_Element_Text('email', array('required' => true, 'label' => 'Email Address:', 'id' => 'email', 'placeholder' => 'Your email..', 'class' => 'form-control', 'type' => 'email')); $validator = new Zend_Validate_EmailAddress(); $input->addValidators(array($validator, new Zend_Validate_NotEmpty())); $input->addDecorator($decoratorField); $elements[] = $input; //Add Submit button $input = new Zend_Form_Element_Submit('submit', array('Label' => '', 'class' => 'btn btn-default', 'value' => 'Reset')); $input->addDecorator($decoratorField); $elements[] = $input; $this->addElements($elements); $this->addDisplayGroup(array('email', 'submit'), 'displgrp', array('decorators' => array('FormElements', 'Fieldset'))); }
public function init() { // Set the method for the display form to POST $this->setMethod('post'); $this->setAttribs(array('class' => 'form-horizontal')); $decoratorField = new My_Decorator_FieldLogin(); $elements = array(); // Add code field $input = new Zend_Form_Element_Text('code', array('required' => true, 'label' => 'Currency Code:', 'id' => 'currency_code', 'placeholder' => 'Example USD', 'class' => 'form-control', 'list' => 'currencies', 'autocomplete' => 'off')); $validator = new Zend_Validate_StringLength(array('max' => 3)); $input->addValidators(array($validator, new Zend_Validate_NotEmpty())); $currencyMapper = new Application_Model_CurrencyMapper(); $decoratorCurrency = new My_Decorator_CurrencyAutocomplete(null, $currencyMapper->getAvailableCurrencies()); $input->addDecorator($decoratorCurrency); $elements[] = $input; //add rate file $input = new Zend_Form_Element_Text('rate', array('required' => true, 'label' => 'Rate:', 'id' => 'rate', 'placeholder' => '...', 'class' => 'form-control', 'step' => 'any', 'type' => 'number')); $input->addValidators(array(new Zend_Validate_Float(), new Zend_Validate_NotEmpty())); $input->addDecorator($decoratorField); $elements[] = $input; // Add checkbox field $input = new Zend_Form_Element_Checkbox('def', array('label' => 'Default', 'id' => 'def', 'class' => 'checkbox', 'type' => 'checkbox')); $decoratorCheckBox = new My_Decorator_CheckBox(); $input->addDecorator($decoratorCheckBox); $elements[] = $input; // Add checkbox field $input = new Zend_Form_Element_Checkbox('active', array('label' => 'Active', 'id' => 'active', 'class' => 'checkbox', 'type' => 'checkbox')); $decoratorCheckBox = new My_Decorator_CheckBox(); $input->addDecorator($decoratorCheckBox); $elements[] = $input; //Add Submit button $input = new Zend_Form_Element_Submit('submit', array('Label' => '', 'class' => 'btn btn-default', 'value' => 'Save')); $input->addDecorator($decoratorField); $elements[] = $input; $this->addElements($elements); $this->addDisplayGroup(array('code', 'rate', 'def', 'active', 'submit'), 'displgrp', array('decorators' => array('FormElements', 'Fieldset'))); }
public function init() { // Set the method for the display form to POST $this->setMethod('post'); $this->setAttribs(array('class' => 'form-horizontal')); $decoratorField = new My_Decorator_FieldLogin(); $elements = array(); // Add name field $input = new Zend_Form_Element_Text('email', array('required' => true, 'label' => 'Email Address:', 'id' => 'email', 'placeholder' => 'Your email..', 'class' => 'form-control', 'type' => 'email')); $input->addValidators(array(new Zend_Validate_EmailAddress(), new Zend_Validate_NotEmpty())); $input->addDecorator($decoratorField); $elements[] = $input; // Add category field $input = new Zend_Form_Element_Password('password1', array('required' => true, 'label' => 'Password:'******'id' => 'password1', 'class' => 'form-control', 'placeholder' => 'Your password..')); $input->addValidators(array(new Zend_Validate_Alnum(), new Zend_Validate_StringLength(array('min' => 8)), new Zend_Validate_NotEmpty())); $input->addDecorator($decoratorField); $elements[] = $input; // Add category field $input = new Zend_Form_Element_Password('password2', array('required' => true, 'label' => 'Password Again:', 'id' => 'password2', 'class' => 'form-control', 'placeholder' => 'Your password again..', 'validators' => array(array('identical', false, array('token' => 'password1'))))); $input->addDecorator($decoratorField); $elements[] = $input; // Add code field $input = new Zend_Form_Element_Text('currency_code', array('required' => true, 'label' => 'Currency Code:', 'id' => 'currency_code', 'placeholder' => 'Example USD', 'class' => 'form-control', 'list' => 'currencies', 'autocomplete' => 'off')); $validator = new Zend_Validate_StringLength(array('max' => 3)); $input->addValidators(array($validator, new Zend_Validate_NotEmpty())); $currencyMapper = new Application_Model_CurrencyMapper(); $currencies = $currencyMapper->fetchAllActive(); $decoratorCurrency = new My_Decorator_CurrencyAutocomplete(null, $currencies); $input->addDecorator($decoratorCurrency); $elements[] = $input; //Add Submit button $input = new Zend_Form_Element_Submit('submit', array('Label' => '', 'class' => 'btn btn-default', 'value' => 'SignUp')); $input->addDecorator($decoratorField); $elements[] = $input; $this->addElements($elements); $this->addDisplayGroup(array('email', 'password1', 'password2', 'currency_code', 'submit'), 'displgrp', array('decorators' => array('FormElements'))); }
public function getSaveProductForm($id) { $form = new Zend_Form(); //get product whitch want update $productMapper = new Application_Model_ProductMapper(); $product = new Application_Model_Product(); if ($id) { $product = $productMapper->getProductById($id); } // Set the method for the display form to POST $form->setMethod('post'); $form->setAttribs(array('class' => 'form-horizontal', 'enctype' => 'multipart/form-data')); $decoratorField = new My_Decorator_Field(); $elements = array(); //Add id hidden field $input = new Zend_Form_Element_Hidden('id', array('value' => $id)); $elements[] = $input; // Add name field $input = new Zend_Form_Element_Text('name', array('required' => true, 'label' => 'Name:', 'id' => 'name', 'placeholder' => 'Type something..', 'value' => $product->getName(), 'class' => 'form-control')); $input->addValidators(array(new Zend_Validate_Alnum(), new Zend_Validate_NotEmpty())); $input->addDecorator($decoratorField); $elements[] = $input; // Add category field $select = new Zend_Form_Element_Select('category_id', array('required' => true, 'label' => 'Category:', 'id' => 'category', 'class' => 'form-control')); $categoryMapper = new Application_Model_CategoryMapper(); $categories = $categoryMapper->fetchAll(); foreach ($categories as $category) { $select->addMultiOption($category->getId(), $category->getName()); } // set selected option $select->setValue($product->getCategoryId()); $select->addDecorator($decoratorField); $elements[] = $select; $currencyMapper = new Application_Model_CurrencyMapper(); $currency = $currencyMapper->getDefaultCurrency(); // Add Price field $input = new Zend_Form_Element_Text('price', array('required' => true, 'label' => 'Price in ' . $currency->getCode() . ':', 'id' => 'price', 'placeholder' => 'Type something..', 'value' => number_format((double) $product->price, 2), 'class' => 'form-control', 'min' => self::MIN, 'max' => self::MAX, 'step' => 'any', 'type' => 'number')); $min = new Zend_Validate_LessThan(self::MAX); $max = new Zend_Validate_GreaterThan(self::MIN); $input->addValidators(array(new Zend_Validate_Float(), $min, $max, new Zend_Validate_NotEmpty())); $input->addDecorator($decoratorField); $elements[] = $input; if ($id) { //Add File field if ($product->file) { $input = new Zend_Form_Element('file', array('label' => 'File:', 'id' => 'file', 'class' => 'form-control', 'value' => $product->file)); $input->addDecorator(new My_Decorator_AnchoraFileForm()); $elements[] = $input; } else { $input = new Zend_Form_Element_File('file', array('label' => 'File:', 'id' => 'file', 'class' => 'form-control')); $input->addDecorator($decoratorField); $elements[] = $input; } //Add Image field if ($product->image) { $input = new Zend_Form_Element('image', array('label' => 'Image:', 'id' => 'image', 'class' => 'form-control', 'value' => $product->image)); $input->addDecorator(new My_Decorator_ImageForm()); $elements[] = $input; } else { $input = new Zend_Form_Element_File('image', array('label' => 'Image:', 'id' => 'image', 'class' => 'form-control')); $input->addDecorator($decoratorField); $elements[] = $input; } } else { //Add File field $input = new Zend_Form_Element_File('file', array('label' => 'File:', 'id' => 'file', 'class' => 'form-control')); $input->addDecorator($decoratorField); $elements[] = $input; //Add Image field $input = new Zend_Form_Element_File('image', array('label' => 'Image:', 'id' => 'image', 'class' => 'form-control')); $input->addDecorator($decoratorField); $elements[] = $input; } //Add Description field $input = new Zend_Form_Element_Textarea('description', array('label' => 'Description:', 'id' => 'description', 'class' => 'form-control', 'value' => $product->description)); $input->addDecorator($decoratorField); $elements[] = $input; //Add Submit button if (!$id) { $input = new Zend_Form_Element_Submit('submit', array('Label' => ' ', 'class' => 'btn btn-success', 'value' => 'Add New Product')); } else { $input = new Zend_Form_Element_Submit('submit', array('Label' => ' ', 'class' => 'btn btn-info', 'value' => 'Update Product')); } $input->addDecorator($decoratorField); $elements[] = $input; $form->addElements($elements); $form->addDisplayGroup(array('name', 'category_id', 'price', 'currency_id', 'file', 'image', 'description', 'submit'), 'displgrp', array('legend' => 'Add Products', 'decorators' => array('FormElements', 'Fieldset'))); return $form; }
/** * Build replyForm * * @return void */ protected function replyForm() { $this->setName('replyForm')->setElementsBelongTo('replyForm'); $element = new Zend_Form_Element_Text('subject', array('disableLoadDefaultDecorators' => true)); $element->addDecorator('ViewHelper')->setAttribs(array('class' => 'input-title', 'maxlength' => 126, 'tabindex' => 1))->addFilter('StripTags')->addFilter('StringTrim'); $this->addElement($element); $element = new Zend_Form_Element_Textarea('body', array('disableLoadDefaultDecorators' => true)); $element->addDecorator('ViewHelper')->setRequired(true)->addErrorMessage('Message cannot be empty!')->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty'); $this->addElement($element); $element = new Zend_Form_Element_Hash('token', array('disableLoadDefaultDecorators' => true)); $element->addDecorator('ViewHelper')->addErrorMessage('Form must not be resubmitted'); $this->addElement($element); $element = new Zend_Form_Element_Submit('replySubmit', array('disableLoadDefaultDecorators' => true)); $element->addDecorator('ViewHelper')->setLabel('Post Reply'); $this->addElement($element); $element = new Zend_Form_Element_Reset('reset', array('disableLoadDefaultDecorators' => true)); $element->addDecorator('ViewHelper')->setLabel('Reset'); $this->addElement($element); $this->clearDecorators(); $this->addDecorator('FormElements')->addDecorator('Form'); /* $this->setName('replyForm') ->setElementsBelongTo('replyForm') ->setMethod('post') ->setEnctype('application/x-www-form-urlencoded'); $subject = new Zend_Form_Element_Text('subject'); $subject->setLabel('Post Subject') ->setAttribs(array('class' => 'input-title', 'maxlength' => 126)) ->setRequired(true) ->addFilter('StripTags') ->addFilter('StringTrim') ->addValidator('NotEmpty'); $message = new Zend_Form_Element_Textarea('message'); $message->setLabel('Your Message') ->setRequired(true) ->addFilter('StripTags') ->addFilter('StringTrim') ->addValidator('NotEmpty'); $posthash = new Zend_Form_Element_Hash('token'); $submit = new Zend_Form_Element_Submit('forumSubmit'); $submit->setLabel('Post Reply'); $this->addElements(array($subject, $message, $posthash, $submit)); */ }