public function init() { parent::init(); $this->setAttrib('enctype', 'multipart/form-data'); $element = new Zend_Form_Element_File('filename'); $element->setLabel('Foto')->setDescription('Maximale grootte van de foto is 1mb')->setRequired(true)->setValidators(array(array('Count', false, 1), array('Size', false, 1024000), array('Extension', false, 'jpg,png,gif')))->setDestination(APPLICATION_PATH . '/../public/images/uploads/holidayhome/photos'); $this->addElement($element); $this->addDisplayGroup(array('filename'), 'photogroup', array('legend' => 'Foto', 'class' => 'file')); $subForm = new Zend_Form_SubForm('Translation'); foreach (Model_Hm_Lang::listAll() as $lang) { $subSubForm = new Zend_Form_SubForm($lang->code); $element = new Zend_Form_Element_Text('title'); $element->setLabel('Titel')->setRequired(true)->setValidators(array(array('stringLength', null, array('min' => 4, 'max' => 64)))); $subSubForm->addElement($element); $element = new Zend_Form_Element_Textarea('description'); $element->setLabel('Omschrijving')->setAttrib('rows', 2)->setAttrib('class', 'autoexpand')->setRequired(true)->setValidators(array(array('stringLength', null, array('min' => 40)))); $subSubForm->addElement($element); $subSubForm->addDisplayGroup(array('title', 'description'), $lang->code, array('class' => 'textarea', 'legend' => $lang->name)); $this->bhvkSubDecorators($subSubForm); $subForm->addSubForm($subSubForm, $lang->code); } $this->bhvkSubDecorators($subForm); $this->addSubForm($subForm, 'Translation'); $element = new Zend_Form_Element_Submit('photo_submit'); $element->setLabel('Verwerken')->setAttrib('class', 'submit'); $this->addElement($element); $this->addDisplayGroup(array('photo_submit'), 'submit', array('class' => 'submit')); $this->bhvkDecorators(); $this->bhvkDecorateSubmit('photo_submit'); $this->bhvkDecorateFile($this->getElement('filename')); }
public function buildForm() { $this->clearElements(); $hourForm = new Zend_Form_SubForm(); foreach ($this->data as $record) { $elm = new Zend_Form_Element((string) $record['id']); $elm->setValue($record); $hourForm->addElement($elm); } $this->addSubForm($hourForm, $this->key_existing); // add template element $newForm = new Zend_Form_SubForm(); $elm = new Zend_Form_Element('__unique__'); $newForm->addElement($elm); // add elements based on $_POST, (this is crap but will do for now) if (isset($_POST['hour_new'])) { foreach ($_POST['hour_new'] as $idx => $values) { if ($idx != '__unique__') { $elm = new Zend_Form_Element($idx); $elm->setValue($values); $newForm->addElement($elm); } } } $this->addSubForm($newForm, $this->key_new); }
/** * Adds extra rows to the form * * @access public * @param mixed $data. (default: null) * @return void */ public function addRows($start, $end) { for ($i = $start; $i < $end; $i++) { $rows = new Zend_Form_SubForm(); $rows->setIsArray(true); $rows->setOrder($i); foreach ($this->_childlist as $col => $name) { switch ($col) { case "item_pack_size_id": $rows->addElement("select", $col, array("attribs" => array("class" => "form-control products"), "filters" => array("StringTrim", "StripTags"), "allowEmpty" => true, "required" => false, "registerInArrayValidator" => false, "multiOptions" => $this->_childlist[$col], "validators" => array(), "belongsTo" => "rows{$i}")); break; case "number": $rows->addElement("select", $col, array("attribs" => array("class" => "form-control manufaturers"), "filters" => array("StringTrim", "StripTags"), "allowEmpty" => true, "required" => false, "registerInArrayValidator" => false, "multiOptions" => $this->_childlist[$col], "validators" => array(), "belongsTo" => "rows{$i}")); break; default: $rows->addElement("select", $col, array("attribs" => array("class" => "form-control"), "filters" => array("StringTrim", "StripTags"), "allowEmpty" => true, "required" => false, "registerInArrayValidator" => false, "multiOptions" => $this->_childlist[$col], "validators" => array(), "belongsTo" => "rows{$i}")); break; } } $rows->addElement("text", "expiry_date", array("attribs" => array("class" => "form-control", 'readonly' => 'true'), "allowEmpty" => false, "filters" => array("StringTrim", "StripTags"), "validators" => array(), "belongsTo" => "rows{$i}")); $rows->addElement("hidden", "hdn_vvm_stage", array("attribs" => array("class" => "form-control", 'readonly' => 'true'), "allowEmpty" => false, "filters" => array("StringTrim", "StripTags"), "validators" => array(), "belongsTo" => "rows{$i}")); $rows->addElement("hidden", "hdn_available_quantity", array("attribs" => array("class" => "form-control", 'readonly' => 'true'), "allowEmpty" => false, "filters" => array("StringTrim", "StripTags"), "validators" => array(), "belongsTo" => "rows{$i}")); $rows->addElement("text", "quantity", array("attribs" => array("class" => "form-control"), "allowEmpty" => false, "filters" => array("StringTrim", "StripTags"), "validators" => array(), "belongsTo" => "rows{$i}")); foreach ($rows->getElements() as $element) { $element->removeDecorator("Label"); $element->removeDecorator("HtmlTag"); } $this->addSubForm($rows, "rows{$i}"); } }
public function buildFromArray(array $array) { $translator = $this->getTranslator(); if (isset($array[$this->getName()])) { $array = $array[$this->getName()]; } foreach ($array as $translationUnit => $variants) { $subForm = new Zend_Form_SubForm(); $this->addSubForm($subForm, $translationUnit); foreach ($variants as $language => $text) { if (is_array($text)) { if (!isset($text['filename']) || !isset($text['contents'])) { throw new Exception('Invalid data structure for HelpPage Form'); } $langSubForm = new Zend_Form_SubForm(); $langSubForm->addElement('hidden', 'filename'); $langSubForm->addElement('textarea', 'contents', array('label' => $translator->translate("setup_language_{$language}"))); $subForm->addSubForm($langSubForm, $language); } else { $subForm->addElement('text', $language, array('label' => $translator->translate("setup_language_{$language}"), 'attribs' => array('size' => 90))); } } $subForm->setLegend($translationUnit); } return $this; }
public function init() { parent::init(); /* * Translations */ $subForm = new Zend_Form_SubForm('Translation'); $langs = Model_Hm_Lang::listAll(); foreach ($langs as $lang) { $subSubForm = new Zend_Form_SubForm($lang->code); $element = new Zend_Form_Element_Text('title'); $element->setLabel('Titel (eigen)')->setDescription('Deze titel is voor gebruik in eigen administratie.')->setRequired(true); $subSubForm->addElement($element); $element = new Zend_Form_Element_Text('display_title'); $element->setLabel('Titel (gebruiker)')->setDescription('Deze titel krijgen de gebruikesr van het systeem te zien.')->setRequired(true); $subSubForm->addElement($element); $element = new Zend_Form_Element_Textarea('description'); $element->setLabel('Omschrijving')->setRequired(true)->setValidators(array(array('stringLength', false, array('min' => 40))))->setAttrib('class', 'autoexpand')->setAttrib('rows', 2); $subSubForm->addElement($element); $subSubForm->addDisplayGroup(array('title', 'display_title', 'description'), $lang->code, array('legend' => $lang->name, 'class' => 'textarea')); $subForm->addSubForm($subSubForm, $lang->code); $this->bhvkSubDecorators($subSubForm); } $this->addSubForm($subForm, 'Translation'); $this->bhvkSubDecorators($subForm); /* * Submit */ $element = new Zend_Form_Element_Submit('submit_chargeoptional'); $element->setLabel('Verwerken')->setAttrib('class', 'submit'); $this->addElement($element); $this->addDisplayGroup(array('submit_chargeoptional'), 'submit', array('class' => 'submit')); $this->bhvkDecorators(); $this->bhvkDecorateSubmitElement($this->getElement('submit_chargeoptional')); }
public function init() { parent::init(); $subForm = new Zend_Form_SubForm('Translation'); $langs = Model_Hm_Lang::listAll(); foreach ($langs as $lang) { $subSubForm = new Zend_Form_SubForm($lang->code); $element = new Zend_Form_Element_Text('name'); $element->setLabel('Naam')->setAttrib('maxlength', 64)->setValidators(array(array('stringLength', false, array('min' => 4, 'max' => 64))))->setRequired(true); $subSubForm->addElement($element); $element = new Zend_Form_Element_Textarea('description'); $element->setLabel('Omschrijving')->setRequired(true)->setValidators(array(array('stringLength', false, array('min' => 40))))->setAttrib('class', 'autoexpand')->setAttrib('rows', 2); $subSubForm->addElement($element); $subSubForm->addDisplayGroup(array('name', 'description'), $lang->code, array('legend' => $lang->name, 'class' => 'textarea')); $subForm->addSubForm($subSubForm, $lang->code); $this->bhvkSubDecorators($subSubForm); } $this->addSubForm($subForm, 'Translation'); $this->bhvkSubDecorators($subForm); $element = new Zend_Form_Element_Submit('submit_category'); $element->setLabel('Verwerken')->setAttrib('class', 'submit'); $this->addElement($element)->addDisplayGroup(array('submit_category'), 'submit', array('class' => 'submit')); $this->bhvkDecorators(); $this->bhvkDecorateSubmit('submit_category'); }
protected function addCustomVariable($varname) { $a = new \Zend_Form_SubForm(); $a->addElement('note', 'title', array('label' => sprintf($this->translate('Custom Variable "%s"'), $varname))); $a->addElement('text', 'description', array('label' => $this->translate('Description'), 'required' => true)); $a->addElement('text', 'default_value', array('label' => $this->translate('Default value'))); $this->addSubForm($a, 'cv_' . $varname); }
/** */ public function init() { $this->addElement('hash', 'csrf'); $this->addElement('select', 'type', array('label' => getGS('Type'), 'required' => true, 'multioptions' => array('reuters' => 'Thomson Reuters'))); $config = new Zend_Form_SubForm(); $config->addElement('text', 'username', array('label' => getGS('Username'), 'required' => true, 'filters' => array('stringTrim'))); $config->addElement('text', 'password', array('label' => getGS('Password'), 'required' => true, 'filters' => array('stringTrim'))); $this->addSubForm($config, 'config'); $this->addElement('submit', 'submit', array('label' => getGS('Add'), 'ignore' => true)); }
/** */ public function initForm(Zend_Form $form, ListView $list, MemberView $member = null) { $newsletter = new Zend_Form_SubForm(); $newsletter->addElement('checkbox', 'subscriber', array('label' => 'I want to receive newsletter')); foreach ($list->groups as $group) { $type = $group['form_field'] == 'radio' ? 'radio' : 'multiCheckbox'; $newsletter->addElement($type, $group['name'], array('label' => $group['name'], 'multioptions' => $group['groups'])); } if ($member !== null) { $newsletter->setDefaults(array_merge((array) $member, $member->groups)); } $form->addSubForm($newsletter, 'newsletter'); }
public function init() { parent::init(); /* * Options */ $element = new Zend_Form_Element_Checkbox('per_person'); $element->setLabel('Per persoon')->setDescription('Selecteer deze optie wanneer u deze kosten per nacht per persoon wilt rekenen. Laat deze optie leeg wanneer u de kosten alleen per nacht wilt rekenen.'); $this->addElement($element); $element = new Zend_Form_Element_Checkbox('visible'); $element->setLabel('Zichtbaar')->setAttrib('checked', 'checked')->setDescription('Selecteer deze optie wanneer u wilt dat de kosten onzichtbaar worden berekend.'); $this->addElement($element); $this->addDisplayGroup(array('per_person', 'visible'), 'info', array('legend' => 'Opties', 'class' => 'checkbox')); /* * Text */ $element = new Zend_Form_Element_Text('exp'); $element->setLabel('Expressies')->setDescription('Waarschuwing! Het is mogelijk om hier speciale expressies in te vullen. Indien u niet weet wat dit is, laat het veld leeg. U kunt de applicatie en betaal processen ernstige schade toebrengen.'); $this->addElement($element); $this->addDisplayGroup(array('exp'), 'expas', array('legend' => 'Expressies')); /* * Translations */ $subForm = new Zend_Form_SubForm('Translation'); $langs = Model_Hm_Lang::listAll(); foreach ($langs as $lang) { $subSubForm = new Zend_Form_SubForm($lang->code); $element = new Zend_Form_Element_Text('title'); $element->setLabel('Titel (eigen)')->setDescription('Deze titel is voor gebruik in eigen administratie.')->setRequired(true); $subSubForm->addElement($element); $element = new Zend_Form_Element_Text('display_title'); $element->setLabel('Titel (gebruiker)')->setDescription('Deze titel krijgen de gebruikesr van het systeem te zien.')->setRequired(true); $subSubForm->addElement($element); $element = new Zend_Form_Element_Textarea('description'); $element->setLabel('Omschrijving')->setRequired(true)->setValidators(array(array('stringLength', false, array('min' => 40))))->setAttrib('class', 'autoexpand')->setAttrib('rows', 2); $subSubForm->addElement($element); $subSubForm->addDisplayGroup(array('title', 'display_title', 'description'), $lang->code, array('legend' => $lang->name, 'class' => 'textarea')); $subForm->addSubForm($subSubForm, $lang->code); $this->bhvkSubDecorators($subSubForm); } $this->addSubForm($subForm, 'Translation'); $this->bhvkSubDecorators($subForm); }
public function init() { $translator = $this->getTranslator(); foreach (array('de', 'en') as $lang) { $langForm = new Zend_Form_SubForm(); $langForm->setLegend($translator->translate("setup_language_{$lang}")); $keyForm = new Zend_Form_SubForm(); $keyForm->addElement('text', 'home_index_index_pagetitle', array('label' => $translator->translate('setup_home_index_index_pagetitle'), 'attribs' => array('size' => 90))); $keyForm->addElement('text', 'home_index_index_title', array('label' => $translator->translate('setup_home_index_index_title'), 'attribs' => array('size' => 90))); $keyForm->addElement('textarea', 'home_index_index_welcome', array('label' => $translator->translate('setup_home_index_index_welcome'), 'attribs' => array('size' => 90))); $keyForm->addElement('textarea', 'home_index_index_instructions', array('label' => $translator->translate('setup_home_index_index_instructions'), 'attribs' => array('size' => 90))); $langForm->addSubForm($keyForm, 'key'); $this->addSubForm($langForm, $lang); } }
public function addTripLines($tripCount = 1, $startDate, $buses = array()) { // create subform $tripLinePanel = new Zend_Form_SubForm(); $tripLinePanel->setDecorators($this->_displayGroupDecorators)->addAttribs(array('class' => 'fieldsetForm span-8')); for ($i = 1; $i <= $tripCount; ++$i) { // create bus element $bus = $this->_createBusElement($buses); // create departure time element $departureTime = $this->_createElement('text', 'departureTime', 'Ngày giờ đi', 'Làm ơn nhập ngày giờ đi', true); $departureTime->setValue($startDate . ' 00:00:00'); $departureTime->addValidator(new TBB_Validate_DepartureTime($startDate)); // create arrival time element $arrivalTime = $this->_createElement('text', 'arrivalTime', 'Ngày giờ đến', 'Làm ơn nhập ngày giờ đến', true); $arrivalTime->setValue($startDate . ' 00:00:00'); $arrivalTime->addValidator(new TBB_Validate_ArrivalTime()); $fare = $this->_createElement('text', 'fare', 'Giá vé', 'Làm ơn nhập giá vé', false, true); // create trip line $tripLine = new Zend_Form_SubForm(); $tripLine->setDecorators($this->_displayGroupDecorators)->addAttribs(array('class' => 'span-7'))->setLegend('Chuyến #' . $i); // add elements to the tripline $tripLine->addElements(array($bus, $departureTime, $arrivalTime, $fare)); $tripLinePanel->addSubForm($tripLine, $i); } // add submit button $submit = $this->_createSubmitButton(); $tripLinePanel->addElement($submit); $this->addSubForm($tripLinePanel, 'tripLines'); }
public function init() { //$this->setSubForms() //$this->setIsArray(true); //$this->setElementsBelongTo('login'); $form = new Zend_Form_SubForm(); $email = $this->createElement('text', 'email'); $email->addValidator('emailaddress')->setRequired(true)->setLabel('Email'); $password = $this->createElement('password', "password")->addValidator('stringLength', false, array(6, 20))->setRequired(true)->setLabel('Password')->setBelongsTo('test'); $submit = $this->createElement('submit', 'submit'); $form->addElement($email)->addElement($password); $form->addElement($submit); $this->setSubForms(array('login' => $form)); if (isset($_GET['redirectTo'])) { $redirectTo = $this->createElement('hidden', 'redirectTo')->setValue($_GET['redirectTo']); $this->addElement($redirectTo); } }
public function getForm() { $form = new Zend_Form(); $form->addElement('text', 'foo')->addElement('text', 'bar')->addElement('text', 'baz')->addElement('text', 'bat'); $subForm = new Zend_Form_SubForm(); $subForm->addElement('text', 'foo')->addElement('text', 'bar')->addElement('text', 'baz')->addElement('text', 'bat'); $form->addDisplayGroup(array('foo', 'bar'), 'foobar')->addSubForm($subForm, 'sub')->setView(new Zend_View()); return $form; }
/** * Inclusão de Elementos * @param array $fields Conjunto de Identificadores e Conteúdo * @return Application_Form_Referencia Próprio Objeto para Encadeamento */ public function addFields(array $fields) { $form = new Zend_Form_SubForm(); foreach ($fields as $identifier => $content) { $element = new Zend_Dojo_Form_Element_TextBox($identifier); $element->setLabel($content)->setRequired(true); $form->addElement($element); } $this->addSubForm($form, 'conteudo'); return $this; }
public function setupForm() { $form1 = new Zend_Form_SubForm(); $form1->addElement('text', 'foo', array('label' => 'Sub Foo: ', 'required' => true, 'validators' => array('NotEmpty', 'Alpha')))->addElement('text', 'bar', array('label' => 'Sub Bar: ', 'required' => true, 'validators' => array('Alpha', 'Alnum'))); $form2 = new Zend_Form(); $form2->addElement('text', 'foo', array('label' => 'Master Foo: ', 'required' => true, 'validators' => array('NotEmpty', 'Alpha')))->addElement('text', 'bar', array('required' => true, 'validators' => array('Alpha', 'Alnum')))->addSubForm($form1, 'sub'); $form2->isValid(array('foo' => '', 'bar' => 'foo 2 u 2', 'sub' => array('foo' => '', 'bar' => 'foo 2 u 2'))); $form2->setView($this->getView()); $this->decorator->setElement($form2); $this->form = $form2; return $form2; }
/** * @return bool|Zend_Form_Subform */ function getOptions() { $menus = Zoo::getService('menu')->fetchAll(); // Build menu tree $tree = new Zoo_Object_Tree($menus, 'id', 'pid'); $options = $tree->getIndentedArray('title', 0, '-'); $form = new Zend_Form_SubForm(); $menu_select = new Zend_Form_Element_Select('menu'); $menu_select->setLabel('Menu'); $menu_select->addMultiOptions($options); $form->addElement($menu_select); return $form; }
public function init() { // Set the form name, method and action $this->setAttrib('name', 'createFormForm'); $this->setAttrib('method', 'post'); $this->setAttrib('action', '/admin/forms/process'); $this->setDecorators(array(array('ViewScript', array('viewScript' => 'partials/_createForm.phtml')))); $this->addElement('text', 'form_name', array('Label' => 'Name', 'required' => true)); $this->addElement('checkbox', 'form_save_db', array('Label' => 'Save to DB')); $this->addElement('checkbox', 'form_send_notification', array('Label' => 'Send Email Notifications')); $subform = new Zend_Form_SubForm(); $subform->addElement('text', 'notification_name', array('Label' => 'Name')); $subform->addElement('text', 'notification_email', array('Label' => 'Email')); $subform->addElement('button', 'addButton', array('Label' => 'Add')); $this->addSubForm($subform, 'notifications'); /** * Buttons */ $this->addElement('button', 'saveCloseButton', array('Label' => 'Save & Close')); $this->getElement('saveCloseButton')->removeDecorator('DtDdWrapper'); $this->addElement('button', 'saveContinueButton', array('Label' => 'Save & Continue')); $this->getElement('saveContinueButton')->removeDecorator('DtDdWrapper'); }
public function cartTable() { $cartTable = $this->cartModel->getForm('cartTable'); $cartTable->setAction($this->view->url(array('controller' => 'cart', 'action' => 'update'), 'default')); // add qty elements, use subform so we can easily get them later $qtys = new Zend_Form_SubForm(); foreach ($this->cartModel as $item) { $qtys->addElement('text', (string) $item->productId, array('value' => $item->qty, 'belongsTo' => 'quantity', 'style' => 'width: 20px;', 'decorators' => array('ViewHelper'))); } $cartTable->addSubForm($qtys, 'qtys'); // add shipping options $cartTable->addElement('select', 'shipping', array('decorators' => array('ViewHelper'), 'MultiOptions' => $this->_getShippingMultiOptions(), 'onChange' => 'this.form.submit();', 'value' => $this->cartModel->getShippingCost())); return $cartTable; }
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(); }
/** * Initialize the form. */ public function init() { parent::init(); $this->setAttrib('id', 'csvimport-mapping'); $this->setMethod('post'); $elementsByElementSetName = $this->_getElementPairs($this->_itemTypeId); $elementsByElementSetName = array('' => 'Select Below') + $elementsByElementSetName; foreach ($this->_columnNames as $index => $colName) { $rowSubForm = new Zend_Form_SubForm(); $selectElement = $rowSubForm->createElement('select', 'element', array('class' => 'map-element', 'multiOptions' => $elementsByElementSetName, 'multiple' => false)); $selectElement->setIsArray(true); if ($this->_automapColumnNamesToElements) { $selectElement->setValue($this->_getElementIdFromColumnName($colName)); } $rowSubForm->addElement($selectElement); $rowSubForm->addElement('checkbox', 'html'); $rowSubForm->addElement('checkbox', 'tags'); $rowSubForm->addElement('checkbox', 'file'); $this->_setSubFormDecorators($rowSubForm); $this->addSubForm($rowSubForm, "row{$index}"); } $this->addElement('submit', 'submit', array('label' => __('Import CSV File'), 'class' => 'submit submit-medium')); }
public function init() { // Set the custom decorator $this->addElementPrefixPath('Shineisp_Decorator', 'Shineisp/Decorator/', 'decorator'); $translate = Shineisp_Registry::get('Zend_Translate'); $this->addElement('textarea', 'note', array('filters' => array('StringTrim'), 'required' => false, 'decorators' => array('Bootstrap'), 'rows' => 5, 'description' => $translate->_('Write here a message for the administrator about this domain.'), 'class' => 'form-control')); $this->addElement('text', 'tags', array('filters' => array('StringTrim'), 'required' => false, 'decorators' => array('Bootstrap'), 'label' => $translate->_('Tags'), 'class' => 'form-control large-input tags')); $this->addElement('text', 'authinfocode', array('filters' => array('StringTrim'), 'required' => false, 'decorators' => array('Bootstrap'), 'label' => $translate->_('Authinfo'), 'class' => 'form-control medium-input')); $this->addElement('select', 'autorenew', array('filters' => array('StringTrim'), 'decorators' => array('Bootstrap'), 'label' => $translate->_('Autorenew'), 'description' => $translate->_('By default, every domain is set with auto-renew option enabled. Choose if the domain must be auto-renew or not at the expiring date.'), 'class' => 'form-control large-input')); $this->getElement('autorenew')->setAllowEmpty(false)->setMultiOptions(array('1' => $translate->_('Yes, I would like to renew the domain at the expiration date.'), '0' => $translate->_('No, I am not interested in the renew.'))); $status = $this->addElement('select', 'status_id', array('label' => $translate->_('Status'), 'decorators' => array('Bootstrap'), 'class' => 'form-control large-input')); $status = $this->getElement('status_id')->setAllowEmpty(false)->setRegisterInArrayValidator(false)->setMultiOptions(Statuses::getList('domains')); $this->addElement('submit', 'submit', array('label' => $translate->_('Save'), 'decorators' => array('Bootstrap'), 'class' => 'btn btn-primary btn-lg')); // Adding a subform $dnsform = new Zend_Form_SubForm(); // Set the decorator $dnsform->addElementPrefixPath('Shineisp_Decorator', 'Shineisp/Decorator/', 'decorator'); $dnsform->addElement('text', 'subdomain', array('filters' => array('StringTrim'), 'decorators' => array('Bootstrap'), 'label' => $translate->_('Subdomain'), 'class' => 'form-control medium-input')); $dnsform->addElement('select', 'zones', array('filters' => array('StringTrim'), 'decorators' => array('Bootstrap'), 'label' => $translate->_('DNS Type Zone'), 'class' => 'form-control large-input')); $dnsform->getElement('zones')->setAllowEmpty(false)->setMultiOptions(Dns_Zones_Types::getZones()); $dnsform->addElement('text', 'target', array('filters' => array('StringTrim'), 'decorators' => array('Bootstrap'), 'label' => $translate->_('Target Address'), 'class' => 'form-control large-input')); $this->addSubForm($dnsform, 'dnsform'); $id = $this->addElement('hidden', 'domain_id'); }
protected function addItemXpathsToExtend($itemXpathsToExtend) { if (count($itemXpathsToExtend) == 0) { $itemXpathsToExtend = array(new Kaltura_Client_Type_String()); } $mainSubForm = new Zend_Form_SubForm(); $mainSubForm->setLegend('Item XPaths To Extend'); $mainSubForm->setDecorators(array('FormElements', array('ViewScript', array('viewScript' => 'distribution-item-xpath-to-extend.phtml', 'placement' => 'APPEND')), 'Fieldset')); $i = 1; foreach ($itemXpathsToExtend as $stringObject) { $subForm = new Zend_Form_SubForm(array('disableLoadDefaultDecorators' => true)); $subForm->setDecorators(array('FormElements')); $subForm->addElement('text', 'itemXpathsToExtend', array('decorators' => array('ViewHelper', array('HtmlTag', array('tag' => 'div'))), 'isArray' => true, 'value' => $stringObject->value)); $mainSubForm->addSubForm($subForm, 'itemXpathsToExtend_subform_' . $i++); } $this->addSubForm($mainSubForm, 'itemXpathsToExtend_group'); }
public function init() { parent::init(); /* * Code */ $element = new Zend_Form_Element_Text('code'); $element->setLabel('Landcode')->setRequired(true); $this->addElement($element); /* * Areacode */ $element = new Zend_Form_Element_Text('area_code'); $element->setLabel('Netnummer')->setRequired(true); $this->addElement($element); $this->addDisplayGroup(array('code', 'area_code'), 'Algemeen', array('legend' => 'Gegevens')); /* * Translations */ $subForm = new Zend_Form_SubForm('Translation'); $langs = Model_Hm_Lang::listAll(); foreach ($langs as $lang) { $subSubForm = new Zend_Form_SubForm($lang->code); /* * Name field */ $element = new Zend_Form_Element_Text('name'); $element->setLabel('Naam')->setAttrib('maxlength', 64)->setValidators(array(array('stringLength', false, array('min' => 4, 'max' => 64))))->setRequired(true); $subSubForm->addElement($element); $subSubForm->addDisplayGroup(array('name'), $lang->code, array('legend' => $lang->name, 'class' => 'textarea')); $subForm->addSubForm($subSubForm, $lang->code); $this->bhvkSubDecorators($subSubForm); } $this->addSubForm($subForm, 'Translation'); $this->bhvkSubDecorators($subForm); /* * Submit */ $element = new Zend_Form_Element_Submit('submit_country'); $element->setLabel("Verwerken")->setAttrib('class', 'submit'); $this->addElement($element); $this->addDisplayGroup(array('submit_country'), 'submit', array('class' => 'submit')); $this->bhvkDecorators(); $this->bhvkDecorateSubmit('submit_country'); }
public function init() { parent::init(); $element = new Zend_Form_Element_Select('hm_geo_region_id'); $element->setLabel('Regio')->setRequired(true)->addMultiOption('', '...'); $regions = Model_Hm_Geo_Region::findAllForAdmin()->execute(); foreach ($regions as $region) { $element->addMultiOption($region->id, $region->Country->translationHandler()->name . ' - ' . $region->name); } $this->addElement($element); $element = new Zend_Form_Element_Text('name'); $element->setLabel('Naam')->setRequired(true)->setAttrib('maxlength', 128)->setValidators(array(array('stringLength', false, array('min' => 4, 'max' => 128)))); $this->addElement($element); $element = new Zend_Form_Element_Text('coordinate'); $element->setLabel('Coordinaat')->setRequired(true)->setAttrib('maxlength', 32)->setValidators(array(array('stringLength', false, array('min' => 4, 'max' => 32)))); $this->addElement($element); $this->addDisplayGroup(array('hm_geo_region_id', 'name', 'coordinate'), 'info', array('legend' => 'Algemeen')); /* * Translations */ $subForm = new Zend_Form_SubForm('Translation'); $langs = Model_Hm_Lang::listAll(); foreach ($langs as $lang) { $subSubForm = new Zend_Form_SubForm($lang->code); /* * Name field */ $element = new Zend_Form_Element_Textarea('description'); $element->setLabel('Omschrijving')->setAttrib('class', 'autoexpand')->setAttrib('rows', 2)->setValidators(array(array('stringLength', false, array('min' => 40))))->setRequired(true); $subSubForm->addElement($element); $subSubForm->addDisplayGroup(array('description'), $lang->code, array('legend' => $lang->name, 'class' => 'textarea')); $subForm->addSubForm($subSubForm, $lang->code); $this->bhvkSubDecorators($subSubForm); } $this->addSubForm($subForm, 'Translation'); $this->bhvkSubDecorators($subForm); $element = new Zend_Form_Element_Submit('submit_city'); $element->setLabel('Verwerken')->setAttrib('class', 'submit'); $this->addElement($element); $this->addDisplayGroup(array('submit_city'), 'submit', array('class' => 'submit')); $this->bhvkDecorators(); $this->bhvkDecorateSubmit('submit_city'); }
public function init() { /* Form Elements & Other Definitions Here ... */ /* $tablaOpcion = new Encuesta_Model_DbTable_Opcion; $rowsetOpciones = $tablaOpcion->fetchAll(); //$eOpciones = new Zend_Form_Element_Multiselect("opciones"); $eOpciones = new Zend_Form_Element_MultiCheckbox("opciones"); $eOpciones->setLabel("Opciones Disponibles:"); //$eOpciones->setAttrib("class", "form-control"); foreach ($rowsetOpciones as $opcion) { $eOpciones->addMultiOption($opcion->idOpcion, $opcion->opcion); } $eSubmit = new Zend_Form_Element_Submit("submit"); $eSubmit->setLabel("Guardar Opciones"); $eSubmit->setAttrib("class", "btn btn-success"); $this->addElement($eOpciones); $this->addElement($eSubmit); */ $categoriaDAO = new Encuesta_DAO_Categoria(); $opcionDAO = new Encuesta_DAO_Opcion(); $modelCategorias = $categoriaDAO->obtenerCategorias(); foreach ($modelCategorias as $modelCategoria) { $sub = new Zend_Form_SubForm(); $sub->setLegend($modelCategoria->getCategoria() . " :: " . $modelCategoria->getDescripcion()); $modelOpciones = $categoriaDAO->obtenerOpciones($modelCategoria->getIdCategoria()); $eElement = new Zend_Form_Element_MultiCheckbox($modelCategoria->getIdCategoria()); foreach ($modelOpciones as $modelOpcion) { $eElement->addMultiOption($modelOpcion->getIdOpcion(), $modelOpcion->getOpcion()); } $sub->addElement($eElement); $this->addSubForm($sub, $modelCategoria->getIdCategoria()); } $eSubmit = new Zend_Form_Element_Submit("submit"); $eSubmit->setLabel("Guardar Opciones"); $eSubmit->setAttrib("class", "btn btn-success"); $this->addElement($eSubmit); }
public function init() { parent::init(); $subForm = new Zend_Form_SubForm('Translation'); $langs = Model_Hm_Lang::listAll(); foreach ($langs as $lang) { $element = new Zend_Form_Element_Textarea('content'); $element->setLabel('Content')->setRequired(true)->setAttrib('class', 'autoexpand')->setAttrib('rows', 2); $subSubForm = new Zend_Form_SubForm($lang->code); $subSubForm->addElement($element)->addDisplayGroup(array('content'), $lang->code, array('legend' => $lang->name, 'class' => 'textarea')); $subForm->addSubForm($subSubForm, $lang->code); $this->bhvkSubDecorators($subSubForm); } $this->addSubForm($subForm, 'Translation'); $this->bhvkSubDecorators($subForm); $element = new Zend_Form_Element_Submit('infomail_submit'); $element->setLabel('Verwerken')->setAttrib('class', 'submit'); $this->addElement($element); $this->addDisplayGroup(array('infomail_submit'), 'submit', array('class' => 'submit')); $this->bhvkDecorators(); $this->bhvkDecorateSubmit('infomail_submit'); }
public function __construct($options = null) { parent::__construct($options); /***************************************/ // Collection subform $collectionForm = new Zend_Form_SubForm(); // Collection name $name = new Zend_Form_Element_Text('NFCS_Name'); $name->setLabel($this->getView()->getCibleText('form_label_collection_name'))->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->setAttrib('class', 'stdTextInput')->setDecorators(array('ViewHelper', array('label', array('placement' => 'append')), array('Errors', array('placement' => 'append')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'label_before_input')))); $collectionForm->addElement($name); /********************************************************/ // Add subform to the form $this->addSubForm($collectionForm, 'collectionForm'); /********************************************************/ // Add button $addFilter = new Zend_Form_Element_Button('addFilterSet'); $addFilter->setLabel($this->getView()->getCibleText('link_add_newsletter_filterSet')); $addFilter->setAttrib('class', 'stdButton'); $addFilter->setDecorators(array('ViewHelper', array(array('data' => 'HtmlTag'), array('tag' => 'li')))); $addFilter->setOrder(2); $this->addActionButton($addFilter); }
public function init() { parent::init(); $subForm = new Zend_Form_SubForm('Translation'); foreach (Model_Hm_Lang::listAll() as $lang) { $subSubForm = new Zend_Form_SubForm($lang->code); $element = new Zend_Form_Element_Textarea('content'); $element->setLabel('Commentaar')->setAttrib('rows', 2)->setAttrib('class', 'autoexpand')->setRequired(true)->setValidators(array(array('stringLength', null, array('min' => 40)))); $subSubForm->addElement($element); $subSubForm->addDisplayGroup(array('content'), $lang->code, array('class' => 'textarea', 'legend' => $lang->name)); $this->bhvkSubDecorators($subSubForm); $subForm->addSubForm($subSubForm, $lang->code); } $this->bhvkSubDecorators($subForm); $this->addSubForm($subForm, 'Translation'); $element = new Zend_Form_Element_Submit('submit_comment'); $element->setLabel('Verwerken')->setAttrib('class', 'submit'); $this->addElement($element); $this->addDisplayGroup(array('submit_comment'), 'submit', array('class' => 'submit')); $this->bhvkDecorators(); $this->bhvkDecorateSubmit('submit_comment'); }
/** * Jedem Language-Element in den Unterformularen wird ein Validator hinzugefügt. Formulare ohne Language-Element * werden ignoriert. */ public function testPrepareValidation() { $form = new Zend_Form(); $titleCount = 3; for ($index = 0; $index < $titleCount; $index++) { $subform = new Zend_Form_SubForm(); $subform->addElement(new Application_Form_Element_Language('Language')); $form->addSubForm($subform, 'Title' . $index); } $subform = new Zend_Form_Subform(); $subform->addElement('submit', 'Add'); $form->addSubForm($subform, 'Actions'); $instance = new Application_Form_Validate_MultiSubForm_RepeatedLanguages(); $post = array('Title0' => array('Id' => '1', 'Language' => 'deu', 'Value' => 'Titel 1'), 'Title1' => array('Id' => '2', 'Language' => 'fra', 'Value' => 'Titel 2'), 'Title2' => array('Id' => '3', 'Language' => 'rus', 'Value' => 'Titel 3'), 'Actions' => array('Add' => 'Add')); $instance->prepareValidation($form, $post); for ($index = 0; $index < $titleCount; $index++) { $subform = $form->getSubForm('Title' . $index); $validator = $subform->getElement('Language')->getValidator('Application_Form_Validate_LanguageUsedOnceOnly'); $this->assertNotNull($validator); $this->assertEquals($index, $validator->getPosition()); $this->assertEquals(array('deu', 'fra', 'rus'), $validator->getLanguages()); } }