Пример #1
0
 public function init()
 {
     $this->setAttrib('id', 'customAttribute');
     // Create and configure username element:
     $label = $this->createElement('text', 'label', array('label' => 'Label:'));
     $label->setRequired(true)->addFilter('StringTrim')->addFilter('StripTags');
     $description = $this->createElement('text', 'description', array('label' => 'Description:'));
     $description->addFilter('StringTrim')->addFilter('StripTags');
     $required = $this->createElement('select', 'required', array('label' => 'Required?'));
     $required->setRequired(true)->setMultiOptions(array('1' => 'Yes', '0' => 'No'))->setAllowEmpty(false);
     $rowCt = $this->createElement('hidden', 'rowCt');
     $rowCt->setValue($this->_numberOfOptions);
     $rowCt->setDecorators(array('ViewHelper'));
     $this->addElements(array($label, $description, $required, $rowCt));
     if ($this->_numberOfOptions != 0) {
         $container = new Zend_Form_SubForm();
         $container->setDescription('Options:');
         $container->setDecorators(array(array('Description', array('tag' => 'label', 'class' => 'control-label')), array('FormElements'), array(array('controlsWrapper' => 'HtmlTag'), array('tag' => 'div', 'class' => 'control-group', 'id' => 'optionElement'))));
         $container->setElementDecorators(array('ViewHelper', 'FormElements'));
         $this->addSubForm($container, 'options');
         for ($i = 0; $i < $this->_numberOfOptions; $i++) {
             $optionSubform = new Ot_Form_CustomAttributeOption();
             $container->addSubForm($optionSubform, $i);
         }
         $this->addElement('button', 'addElement', array('buttonType' => Twitter_Bootstrap_Form_Element_Submit::BUTTON_SUCCESS, 'label' => 'Add Option', 'icon' => 'plus', 'whiteIcon' => true, 'iconPosition' => Twitter_Bootstrap_Form_Element_Button::ICON_POSITION_LEFT));
     }
     $this->addElement('submit', 'submit', array('buttonType' => Twitter_Bootstrap_Form_Element_Submit::BUTTON_PRIMARY, 'label' => 'Save Attribute'));
     $this->addElement('button', 'cancel', array('label' => 'form-button-cancel', 'type' => 'button'));
     $this->addDisplayGroup(array('submit', 'cancel'), 'actions', array('disableLoadDefaultDecorators' => true, 'decorators' => array('Actions')));
     return $this;
 }
Пример #2
0
 public function init()
 {
     $this->setName('addApplicant');
     $id = new Zend_Form_Element_Hidden('id');
     $id->addFilter('Int');
     $product = new Zend_Form_Element_Text('product');
     $product->setLabel('* product:')->setRequired(true)->addFilter('StripTags')->addFilter('stringTrim')->addValidators(array(array('regex', false, array('pattern' => "/^[а,б,в,г,ґ,д,е,є,ж,з,и,ы,і,ї,й,к,л,м,н,о,п,р,с,т,у,ф,х,ц,ч,ш,щ,ь,ю,я,А,Б,В,С,Г,Д,Е,Є,Ж,З,И,Ы,І,Ї,Й,К,Л,М,Н,О,П,Р,С,Т,У,Ф,Х,Ц,Ч,Ш,Щ,Ь,Ю,Я,A,a,B,b,C,c,D,d,E,e,F,f,G,g,H,h,I,i,J,j,K,k,L,l,M,m,N,n,O,o,P,p,Q,q,R,r,S,s,T,t,U,u,V,v,W,w,X,x,Y,y,Z,z,1,2,3,4,5,6,7,8,9,0'.]{2,}\$/", 'messages' => 'В полі присутні заборонені символи!!'))));
     $category = new Zend_Form_Element_Text('category');
     $category->setLabel("* category:")->setRequired(true)->addFilter('StripTags')->addFilter('stringTrim')->addValidators(array(array('regex', false, array('pattern' => "/^[а,б,в,г,ґ,д,е,є,ж,з,и,ы,і,ї,й,к,л,м,н,о,п,р,с,т,у,ф,х,ц,ч,ш,щ,ь,ю,я,А,Б,В,С,Г,Д,Е,Є,Ж,З,И,Ы,І,Ї,Й,К,Л,М,Н,О,П,Р,С,Т,У,Ф,Х,Ц,Ч,Ш,Щ,Ь,Ю,Я,A,a,B,b,C,c,D,d,E,e,F,f,G,g,H,h,I,i,J,j,K,k,L,l,M,m,N,n,O,o,P,p,Q,q,R,r,S,s,T,t,U,u,V,v,W,w,X,x,Y,y,Z,z,1,2,3,4,5,6,7,8,9,0'.]{2,}\$/", 'messages' => 'В полі присутні заборонені символи!!'))));
     $group = new Zend_Form_Element_Text('group');
     $group->setLabel("* group:")->setRequired(true)->addFilter('StripTags')->addFilter('stringTrim')->addValidators(array(array('regex', false, array('pattern' => "/^[а,б,в,г,ґ,д,е,є,ж,з,и,ы,і,ї,й,к,л,м,н,о,п,р,с,т,у,ф,х,ц,ч,ш,щ,ь,ю,я,А,Б,В,С,Г,Д,Е,Є,Ж,З,И,Ы,І,Ї,Й,К,Л,М,Н,О,П,Р,С,Т,У,Ф,Х,Ц,Ч,Ш,Щ,Ь,Ю,Я,A,a,B,b,C,c,D,d,E,e,F,f,G,g,H,h,I,i,J,j,K,k,L,l,M,m,N,n,O,o,P,p,Q,q,R,r,S,s,T,t,U,u,V,v,W,w,X,x,Y,y,Z,z,1,2,3,4,5,6,7,8,9,0'.]{2,}\$/", 'messages' => 'В полі присутні заборонені символи!!'))));
     $this->addElements(array($id, $product, $category, $group));
     //-------------------- add attr
     $institutions = new Zend_Form_SubForm();
     $institutions->setName('attr');
     $session = new Zend_Session_Namespace('form');
     foreach ($session->attr as $inst) {
         $rowForm = new Zend_Form_SubForm();
         $rowForm->setName($inst);
         if ($inst === '__template1__') {
             $rowForm->setAttrib('style', 'display: none;');
         }
         $instName = new Zend_Form_Element_Text('instName');
         $instName->setLabel('attribute')->addFilter('StripTags')->addFilter('stringTrim')->setAttrib('class', 'institution')->setAttrib('onfocus', 'institutionAutocomplete(this)');
         if ($inst !== '__template1__') {
             $instName->setRequired(true);
         }
         $inst_remove = new Zend_Form_Element_Button('remove');
         $inst_remove->setLabel('remove')->setAttrib('class', 'remove')->setAttrib('onclick', 'removeInst(this)');
         $elements = array($instName, $inst_remove);
         foreach ($elements as $element) {
             if ($inst !== '__template1__' && $element->getName() !== 'remove') {
                 $element->setRequired(true);
             }
         }
         $rowForm->addElements($elements);
         $rowForm->setElementDecorators($this->getElementDecorators());
         $rowForm->getElement('remove')->removeDecorator('Label');
         $rowForm->setDecorators($this->getSubFormDecorators());
         $institutions->addSubForm($rowForm, $inst);
     }
     $institutions->setDecorators($this->getSubFormDecorators());
     $inst_add = new Zend_Form_Element_Button('addInst');
     $inst_add->setLabel('add attribute')->setAttrib('class', 'addInst');
     $institutions->addElement($inst_add);
     $institutions->setElementDecorators($this->getElementDecorators());
     $institutions->getElement('addInst')->removeDecorator('Label');
     $this->addSubForm($institutions, 'institutions');
     $this->postSetup();
 }