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(); }
/** * Create the custom registrars parameters * * @param integer $attribute_group_id */ public static function createRegistrarForm($form, $registrar_name) { $config = null; $attributeForm = new Zend_Form_SubForm(); $attributeForm->addElementPrefixPath('Shineisp_Decorator', 'Shineisp/Decorator/', 'decorator'); $configfile = PROJECT_PATH . "/library/Shineisp/Plugins/Registrars/" . $registrar_name . "/config.xml"; if (file_exists($configfile)) { $config = simplexml_load_file($configfile); foreach ($config->settings->children() as $node) { $arr = $node->attributes(); $var = strtolower($config['var']) . "_" . (string) $arr['var']; $label = (string) $arr['label']; $type = (string) $arr['type']; $description = (string) $arr['description']; $default = (string) $arr['default']; $required = (string) $arr['required']; if (!empty($var) && !empty($label) && !empty($type)) { // Create the element $attributeForm->addElement($type, $var, array('label' => $label, 'class' => 'form-control', 'decorators' => array('Bootstrap'), 'description' => $description)); if ($required) { $attributeForm->getElement($var)->setRequired(true); } // Handle the default option items for the dropdown selector if ($type == "select") { $items = trim((string) $node); $data = !empty($items) ? json_decode($items, true) : array(); $attributeForm->getElement($var)->setAllowEmpty(false)->setRegisterInArrayValidator(false)->setMultiOptions($data); } if (!empty($default)) { $attributeForm->getElement($var)->setValue($default); } $form->addSubForm($attributeForm, 'settings'); } } } return array($form, $config); }
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_ExtendingItemMrssParameter()); } $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; $extendCategory = false; $extendParentCategory = false; foreach ($itemXpathsToExtend as $itemXPath) { /* @var $itemXPath Kaltura_Client_Type_ExtendingItemMrssParameter */ //if it a category identifier if ($itemXPath->identifier instanceof Kaltura_Client_Type_CategoryIdentifier) { /* @var $identifier Kaltura_Client_Type_CategoryIdentifier */ $identifier = $itemXPath->identifier; //if the parameters are set exactly as the admin console sets. if ($itemXPath->xpath == '//category' && $itemXPath->extensionMode == Kaltura_Client_Enum_MrssExtensionMode::REPLACE && $identifier->identifier == Kaltura_Client_Enum_CategoryIdentifierField::FULL_NAME) { foreach (explode(',', $identifier->extendedFeatures) as $extendedFeature) { if ($extendedFeature == Kaltura_Client_Enum_ObjectFeatureType::METADATA) { $extendCategory = true; } elseif ($extendedFeature == Kaltura_Client_Enum_ObjectFeatureType::ANCESTOR_RECURSIVE) { $extendParentCategory = true; } } } continue; } $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' => $itemXPath->xpath)); $mainSubForm->addSubForm($subForm, 'itemXpathsToExtend_subform_' . $i++); } //set the extend category metadata checkbox $subForm = new Zend_Form_SubForm(array('disableLoadDefaultDecorators' => true)); $subForm->setDecorators(array('FormElements')); $subForm->addElement('checkbox', 'includeCategoryInMrss', array('label' => 'Include category-level custom metadata in MRSS', 'isArray' => true, 'value' => $extendCategory)); $subForm->getElement('includeCategoryInMrss')->getDecorator('Label')->setOption('placement', 'APPEND'); $subForm->getElement('includeCategoryInMrss')->setChecked($extendCategory); $mainSubForm->addSubForm($subForm, 'itemXpathsToExtend_subform_' . $i++, 99); //set the extend category parent metadata checkbox $subForm = new Zend_Form_SubForm(array('disableLoadDefaultDecorators' => true)); $subForm->setDecorators(array('FormElements')); $subForm->addElement('checkbox', 'includeCategoryParentInMrss', array('label' => 'Include parent categories', 'isArray' => true, 'value' => $extendParentCategory)); $subForm->getElement('includeCategoryParentInMrss')->getDecorator('Label')->setOption('placement', 'APPEND'); $subForm->getElement('includeCategoryParentInMrss')->setChecked($extendParentCategory); $mainSubForm->addSubForm($subForm, 'itemXpathsToExtend_subform_' . $i++, 100); $this->addSubForm($mainSubForm, 'itemXpathsToExtend_group'); }
public function init() { // Set the form name, method and action $this->setAttrib('name', 'registerForm'); $this->setAttrib('method', 'post'); $this->setAttrib('action', '/error'); /** * Agent Subform */ $agent = new Zend_Form_SubForm(); $agent->setDecorators(array(array('ViewScript', array('viewScript' => 'partials/_agent.phtml')))); // Business Name Element $agent->addElement('text', 'agent_business', array('filters' => array('StringTrim'), 'label' => 'Business Name:', 'required' => true, 'belongsTo' => 'agent', 'validators' => array(array('NotEmpty', true), array('StringLength', true, array(1, 150))))); // First Name Element $agent->addElement('text', 'agent_fname', array('filters' => array('StringTrim'), 'label' => 'First Name:', 'required' => true, 'belongsTo' => 'agent', 'validators' => array(array('NotEmpty', true), array('StringLength', true, array(1, 150))))); // Last Name Element $agent->addElement('text', 'agent_lname', array('filters' => array('StringTrim'), 'label' => 'Last Name:', 'required' => true, 'belongsTo' => 'agent', 'validators' => array(array('NotEmpty', true), array('StringLength', true, array(1, 150))))); // Address1 Element $agent->addElement('text', 'agent_address1', array('filters' => array('StringTrim'), 'label' => 'Address1:', 'required' => true, 'belongsTo' => 'agent', 'validators' => array(array('NotEmpty', true), array('StringLength', true, array(1, 150))))); // Address2 Element $agent->addElement('text', 'agent_address2', array('filters' => array('StringTrim'), 'label' => 'Address2:', 'required' => false, 'belongsTo' => 'agent', 'validators' => array(array('NotEmpty', true), array('StringLength', true, array(1, 150))))); // City Element $agent->addElement('text', 'agent_city', array('filters' => array('StringTrim'), 'label' => 'City:', 'required' => true, 'belongsTo' => 'agent', 'validators' => array(array('NotEmpty', true), array('StringLength', true, array(1, 150))))); // State Element $agent->addElement('text', 'agent_state', array('filters' => array('StringTrim'), 'label' => 'State:', 'required' => true, 'belongsTo' => 'agent', 'validators' => array(new FFR_Form_Validator_ValidUnitedStates(), array('NotEmpty', true), array('StringLength', true, array(1, 50))))); // Zipcode Element $agent->addElement('text', 'agent_zip', array('filters' => array('StringTrim'), 'label' => 'Zipcode:', 'required' => true, 'belongsTo' => 'agent', 'validators' => array(new FFR_Form_Validator_ValidZipCode(), array('NotEmpty', true), array('StringLength', true, array(1, 10))))); // Work Phone Element $agent->addElement('text', 'agent_workphone', array('filters' => array('StringTrim'), 'label' => 'Work Phone:', 'required' => true, 'belongsTo' => 'agent', 'validators' => array(new FFR_Form_Validator_ValidPhone(), array('NotEmpty', true), array('StringLength', true, array(1, 15))))); // Cell Phone Element $agent->addElement('text', 'agent_cellphone', array('filters' => array('StringTrim'), 'label' => 'Cell Phone:', 'required' => false, 'belongsTo' => 'agent', 'validators' => array(new FFR_Form_Validator_ValidPhone(), array('NotEmpty', true), array('StringLength', true, array(1, 15))))); // Fax Element $agent->addElement('text', 'agent_fax', array('filters' => array('StringTrim'), 'label' => 'Fax:', 'required' => false, 'belongsTo' => 'agent', 'validators' => array(new FFR_Form_Validator_ValidPhone(), array('NotEmpty', true), array('StringLength', true, array(1, 15))))); // Email Element $agent->addElement('text', 'agent_email', array('filters' => array('StringTrim', 'StringToLower'), 'label' => 'Email:', 'required' => true, 'belongsTo' => 'agent', 'validators' => array(array('NotEmpty', true), array('StringLength', true, array(1, 150)), array('EmailAddress')))); /** * User Subform */ $user = new Zend_Form_SubForm(); $user->setDecorators(array(array('ViewScript', array('viewScript' => 'partials/_user.phtml')))); // Username Element $user->addElement('text', 'user_username', array('filters' => array('StringTrim', 'StringToLower'), 'label' => 'Username:'******'required' => true, 'belongsTo' => 'user', 'validators' => array(array('NotEmpty', true), 'Alnum', array('Regex', false, array('/^[a-z][a-z0-9]{3,20}$/')), array('Db_NoRecordExists', true, array('table' => 'user', 'field' => 'user_username'))))); $user->getElement('user_username')->getValidator('Db_NoRecordExists')->setMessages(array('recordFound' => 'That username is already taken. Please choose another.')); // Password Element $user->addElement('password', 'user_password', array('filters' => array('StringTrim'), 'label' => 'Password:'******'required' => true, 'belongsTo' => 'user', 'validators' => array(array('NotEmpty', true), array('StringLength', true, array(6))))); // Password Verify Element $user->addElement('password', 'password_confirm', array('filters' => array('StringTrim'), 'label' => 'Confirm Password:'******'required' => true, 'belongsTo' => 'user', 'validators' => array(array('NotEmpty', true), array('StringLength', true, array(6))))); // User Active Element $user->addElement('hidden', 'user_active', array('belongsTo' => 'user', 'required' => true, 'value' => '0')); $user->addElement('hidden', 'user_perms', array('belongsTo' => 'user', 'required' => true, 'value' => 'a:2:{s:5:"roles";a:1:{i:0;s:5:"Agent";}s:13:"acl_resources";a:0:{}}')); /** * Account Subform */ $account = new Zend_Form_SubForm(); $account->setDecorators(array(array('ViewScript', array('viewScript' => 'partials/_account.phtml')))); // Business Name Element $account->addElement('text', 'account_business', array('filters' => array('StringTrim'), 'label' => 'Business Name:', 'required' => true, 'belongsTo' => 'account', 'validators' => array(array('NotEmpty', true), array('StringLength', true, array(1, 150))))); // First Name Element $account->addElement('text', 'account_fname', array('filters' => array('StringTrim'), 'label' => 'First Name:', 'required' => true, 'belongsTo' => 'account', 'validators' => array(array('NotEmpty', true), array('StringLength', true, array(1, 150))))); // Last Name Element $account->addElement('text', 'account_lname', array('filters' => array('StringTrim'), 'label' => 'Last Name:', 'required' => true, 'belongsTo' => 'account', 'validators' => array(array('NotEmpty', true), array('StringLength', true, array(1, 150))))); // Address1 Element $account->addElement('text', 'account_address1', array('filters' => array('StringTrim'), 'label' => 'Address1:', 'required' => true, 'belongsTo' => 'account', 'validators' => array(array('NotEmpty', true), array('StringLength', true, array(1, 150))))); // Address2 Element $account->addElement('text', 'account_address2', array('filters' => array('StringTrim'), 'label' => 'Address2:', 'required' => false, 'belongsTo' => 'account', 'validators' => array(array('NotEmpty', true), array('StringLength', true, array(1, 150))))); // City Element $account->addElement('text', 'account_city', array('filters' => array('StringTrim'), 'label' => 'City:', 'required' => true, 'belongsTo' => 'account', 'validators' => array(array('NotEmpty', true), array('StringLength', true, array(1, 150))))); // State Element $account->addElement('text', 'account_state', array('filters' => array('StringTrim'), 'label' => 'State:', 'required' => true, 'belongsTo' => 'account', 'validators' => array(new FFR_Form_Validator_ValidUnitedStates(), array('NotEmpty', true), array('StringLength', true, array(1, 50))))); // Zipcode Element $account->addElement('text', 'account_zip', array('filters' => array('StringTrim'), 'label' => 'Zipcode:', 'required' => true, 'belongsTo' => 'account', 'validators' => array(new FFR_Form_Validator_ValidZipCode(), array('NotEmpty', true), array('StringLength', true, array(1, 10))))); // Work Phone Element $account->addElement('text', 'account_workphone', array('filters' => array('StringTrim'), 'label' => 'Work Phone:', 'required' => true, 'belongsTo' => 'account', 'validators' => array(new FFR_Form_Validator_ValidPhone(), array('NotEmpty', true), array('StringLength', true, array(1, 15))))); // Cell Phone Element $account->addElement('text', 'account_cellphone', array('filters' => array('StringTrim'), 'label' => 'Cell Phone:', 'required' => false, 'belongsTo' => 'account', 'validators' => array(new FFR_Form_Validator_ValidPhone(), array('NotEmpty', true), array('StringLength', true, array(1, 15))))); // Fax Element $account->addElement('text', 'account_fax', array('filters' => array('StringTrim'), 'label' => 'Fax:', 'required' => false, 'belongsTo' => 'account', 'validators' => array(new FFR_Form_Validator_ValidPhone(), array('NotEmpty', true), array('StringLength', true, array(1, 15))))); // Email Element $account->addElement('text', 'account_email', array('filters' => array('StringTrim', 'StringToLower'), 'label' => 'Email:', 'required' => true, 'belongsTo' => 'account', 'validators' => array(array('NotEmpty', true), array('StringLength', true, array(1, 150)), array('EmailAddress')))); /** * Attach sub forms to main form */ $this->addSubForms(array('agent' => $agent, 'user' => $user, 'account' => $account)); /** * Buttons */ $this->addElement('button', 'saveCloseButton', array('Label' => 'Save & Close', 'class' => 'ui-state-default float-left ui-corner-all ui-button')); $this->getElement('saveCloseButton')->removeDecorator('DtDdWrapper'); $this->addElement('button', 'saveContinueButton', array('Label' => 'Save & Continue', 'class' => 'ui-state-default float-right ui-corner-all ui-button')); $this->getElement('saveContinueButton')->removeDecorator('DtDdWrapper'); }
public function __construct($options = null) { $this->_disabledDefaultActions = true; parent::__construct($options); $baseDir = $this->getView()->baseUrl(); if (!empty($options['mode']) && $options['mode'] == 'edit') { $this->_mode = 'edit'; } else { $this->_mode = 'add'; } $langId = Zend_Registry::get('languageID'); $this->setAttrib('id', 'accountManagement'); $this->setAttrib('class', 'step3'); // $addressParams = array( // "fieldsValue" => array(), // "display" => array(), // "required" => array(), // ); //Hidden fields for the state and cities id $selectedState = new Zend_Form_Element_Hidden('selectedState'); $selectedState->removeDecorator('label'); $selectedCity = new Zend_Form_Element_Hidden('selectedCity'); $selectedCity->removeDecorator('label'); $this->addElement($selectedState); $this->addElement($selectedCity); // Salutation $salutation = new Zend_Form_Element_Select('salutation'); $salutation->setLabel($this->getView()->getCibleText('form_label_salutation'))->setAttrib('class', 'smallTextInput')->setOrder(1); $greetings = $this->getView()->getAllSalutation(); foreach ($greetings as $greeting) { $salutation->addMultiOption($greeting['S_ID'], $greeting['ST_Value']); } // language hidden field $language = new Zend_Form_Element_Hidden('language', array('value' => $langId)); $language->removeDecorator('label'); // langauge hidden field // FirstName $firstname = new Zend_Form_Element_Text('firstName'); $firstname->setLabel($this->getView()->getCibleText('form_label_fName'))->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->setAttribs(array('class' => 'stdTextInput'))->setOrder(2); // LastName $lastname = new Zend_Form_Element_Text('lastName'); $lastname->setLabel($this->getView()->getCibleText('form_label_lName'))->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->setAttribs(array('class' => 'stdTextInput'))->setOrder(3); // email $regexValidate = new Cible_Validate_Email(); $regexValidate->setMessage($this->getView()->getCibleText('validation_message_emailAddressInvalid'), 'regexNotMatch'); $emailNotFoundInDBValidator = new Zend_Validate_Db_NoRecordExists('GenericProfiles', 'GP_Email'); $emailNotFoundInDBValidator->setMessage($this->getView()->getClientText('validation_message_email_already_exists'), 'recordFound'); $email = new Zend_Form_Element_Text('email'); $email->setLabel($this->getView()->getCibleText('form_label_email'))->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addFilter('StringToLower')->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->addValidator($regexValidate)->setAttribs(array('maxlength' => 50, 'class' => 'stdTextInput'))->setOrder(4); if ($this->_mode == 'add') { $email->addValidator($emailNotFoundInDBValidator); } // email // password $password = new Zend_Form_Element_Password('password'); if ($this->_mode == 'add') { $password->setLabel($this->getView()->getCibleText('form_label_password')); } else { $password->setLabel($this->getView()->getCibleText('form_label_newPwd')); } $password->addFilter('StripTags')->addFilter('StringTrim')->setAttrib('class', 'stdTextInput')->setRequired(true)->setOrder(5)->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field')))); // password // password confirmation $passwordConfirmation = new Zend_Form_Element_Password('passwordConfirmation'); if ($this->_mode == 'add') { $passwordConfirmation->setLabel($this->getView()->getCibleText('form_label_confirmPwd')); } else { $passwordConfirmation->setLabel($this->getView()->getCibleText('form_label_confirmNewPwd')); } $passwordConfirmation->addFilter('StripTags')->addFilter('StringTrim')->setRequired(true)->setOrder(6)->setAttrib('class', 'stdTextInput'); if (!empty($_POST['identification']['password'])) { $passwordConfirmation->setRequired(true)->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('error_message_password_isEmpty')))); $Identical = new Zend_Validate_Identical($_POST['identification']['password']); $Identical->setMessages(array('notSame' => $this->getView()->getCibleText('error_message_password_notSame'))); $passwordConfirmation->addValidator($Identical); } // password confirmation // Company name $company = new Zend_Form_Element_Text('company'); $company->setLabel($this->getView()->getCibleText('form_label_company'))->setRequired(false)->setOrder(7)->setAttribs(array('class' => 'stdTextInput')); // function in company $functionCompany = new Zend_Form_Element_Text('functionCompany'); $functionCompany->setLabel($this->getView()->getCibleText('form_label_account_function_company'))->setRequired(false)->setOrder(8)->setAttribs(array('class' => 'stdTextInput')); // Are you a retailer $retailer = new Zend_Form_Element_Select('isRetailer'); $retailer->setLabel($this->getView()->getClientText('form_label_retailer'))->setAttrib('class', 'smallTextInput'); $retailer->addMultiOption(0, $this->getView()->getCibleText('button_no')); $retailer->addMultiOption(1, $this->getView()->getCibleText('button_yes')); // Text Subscribe $textSubscribe = $this->getView()->getCibleText('form_label_subscribe'); $textSubscribe = str_replace('%URL_PRIVACY_POLICY%', Cible_FunctionsPages::getPageLinkByID($this->_config->page_privacy_policy->pageID), $textSubscribe); // Newsletter subscription $newsletterSubscription = new Zend_Form_Element_Checkbox('newsletterSubscription'); $newsletterSubscription->setLabel($textSubscribe); if ($this->_mode == 'add') { $newsletterSubscription->setChecked(1); } $newsletterSubscription->setAttrib('class', 'long-text'); $newsletterSubscription->setDecorators(array('ViewHelper', array('label', array('placement' => 'append')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'label_after_checkbox')))); if ($this->_mode == 'add') { $termsAgreement = new Zend_Form_Element_Checkbox('termsAgreement'); $termsAgreement->setLabel(str_replace('%URL_TERMS_CONDITIONS%', Cible_FunctionsPages::getPageLinkByID($this->_config->termsAndConditions->pageId), $this->getView()->getClientText('form_label_terms_agreement'))); $termsAgreement->setAttrib('class', 'long-text'); $termsAgreement->setDecorators(array('ViewHelper', array('label', array('placement' => 'append')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'label_after_checkbox')))); $termsAgreement->setRequired(true); $termsAgreement->addValidator('notEmpty', true, array('messages' => array('isEmpty' => 'You must agree to the terms'))); } else { $termsAgreement = new Zend_Form_Element_Hidden('termsAgreement', array('value' => 1)); } // Submit button $submit = new Zend_Form_Element_Submit('submit'); $submit->setLabel($this->getView()->getCibleText('form_label_next_step_btn'))->setAttrib('class', 'nextStepButton'); // Reference number for the job $txtConnaissance = new Cible_Form_Element_Html('knowYou', array('value' => $this->getView()->getCibleText('form_account_mieux_vous_connaitre_legend'))); $txtConnaissance->setDecorators(array('ViewHelper', array('label', array('placement' => 'prepend')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'description left')))); $refJobId = new Zend_Form_Element_Text('refJobId'); $refJobId->setLabel('refJobId')->setRequired(false)->setAttribs(array('class' => 'stdTextInput')); // Reference number for the role $refRoleId = new Zend_Form_Element_Text('refRoleId'); $refRoleId->setLabel('refRoleId')->setRequired(false)->setAttribs(array('class' => 'stdTextInput')); // Reference number for the job title $refJobTitleId = new Zend_Form_Element_Text('refJobTitleId'); $refJobTitleId->setLabel('refJobTitleId')->setRequired(false)->setAttribs(array('class' => 'stdTextInput')); $refJobTitleId = new Zend_Form_Element_Text('refJobTitleId'); $refJobTitleId->setLabel('refJobTitleId')->setRequired(false)->setAttribs(array('class' => 'stdTextInput')); // Provincial tax exemption $noProvTax = new Zend_Form_Element_Checkbox('noProvTax'); $noProvTax->setLabel($this->getView()->getCibleText('form_label_account_provincial_tax')); $noProvTax->setAttrib('class', 'long-text')->setOrder(13); $noProvTax->setDecorators(array('ViewHelper', array('label', array('placement' => 'append')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'label_after_checkbox')))); // Provincial tax exemption $noFedTax = new Zend_Form_Element_Checkbox('noFedTax'); $noFedTax->setLabel($this->getView()->getCibleText('form_label_account_federal_tax')); $noFedTax->setAttrib('class', 'long-text')->setOrder(14); $noFedTax->setDecorators(array('ViewHelper', array('label', array('placement' => 'append')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'label_after_checkbox')))); /* Identification sub form */ $identificationSub = new Zend_Form_SubForm(); $identificationSub->setName('identification')->removeDecorator('DtDdWrapper'); $identificationSub->setLegend($this->getView()->getCibleText('form_account_subform_identification_legend')); $identificationSub->setAttrib('class', 'identificationClass subFormClass'); $identificationSub->addElement($language); $identificationSub->addElement($salutation); $identificationSub->addElement($lastname); $identificationSub->addElement($firstname); $identificationSub->addElement($email); $identificationSub->addElement($password); $identificationSub->addElement($passwordConfirmation); $identificationSub->addElement($company); $this->addSubForm($identificationSub, 'identification'); // $identificationSub->addElement($functionCompany); $addrContactMedia = new Cible_View_Helper_FormAddress($identificationSub); if ($options['resume']) { $addrContactMedia->setProperty('addScript', false); } $addrContactMedia->enableFields(array('firstTel', 'secondTel', 'fax', 'webSite')); $addrContactMedia->formAddress(); $identificationSub->addElement($noProvTax); $identificationSub->addElement($noFedTax); /* Identification sub form */ /* billing address */ // Billing address $addressFacturationSub = new Zend_Form_SubForm(); $addressFacturationSub->setName('addressFact')->removeDecorator('DtDdWrapper'); $addressFacturationSub->setLegend($this->getView()->getCibleText('form_account_subform_addBilling_legend')); $addressFacturationSub->setAttrib('class', 'addresseBillingClass subFormClass'); $billingAddr = new Cible_View_Helper_FormAddress($addressFacturationSub); $billingAddr->setProperty('addScriptState', false); if ($options['resume']) { $billingAddr->setProperty('addScript', false); } $billingAddr->enableFields(array('firstAddress', 'secondAddress', 'state', 'cityTxt', 'zipCode', 'country', 'firstTel', 'secondTel')); $billingAddr->formAddress(); $addrBill = new Zend_Form_Element_Hidden('addrBill'); $addrBill->removeDecorator('label'); $addressFacturationSub->addElement($addrBill); $addressFacturationSub->getElement('AI_SecondAddress')->removeDecorator('label'); $this->addSubForm($addressFacturationSub, 'addressFact'); /* delivery address */ $addrShip = new Zend_Form_Element_Hidden('addrShip'); $addrShip->removeDecorator('label'); $addressShippingSub = new Zend_Form_SubForm(); $addressShippingSub->setName('addressShipping')->removeDecorator('DtDdWrapper'); $addressShippingSub->setLegend($this->getView()->getCibleText('form_account_subform_addShipping_legend')); $addressShippingSub->setAttrib('class', 'addresseShippingClass subFormClass'); $shipAddr = new Cible_View_Helper_FormAddress($addressShippingSub); if ($options['resume']) { $shipAddr->setProperty('addScript', false); } $shipAddr->duplicateAddress($addressShippingSub); $shipAddr->setProperty('addScriptState', false); $shipAddr->enableFields(array('firstAddress', 'secondAddress', 'state', 'cityTxt', 'zipCode', 'country', 'firstTel', 'secondTel')); $shipAddr->formAddress(); $addressShippingSub->addElement($addrShip); $this->addSubForm($addressShippingSub, 'addressShipping'); if ($this->_mode == 'edit') { $this->addElement($termsAgreement); } $this->addElement($submit); $submit->setDecorators(array('ViewHelper', array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'stepBottomNext')))); if ($this->_mode == 'add') { $termsAgreement->setDecorators(array('ViewHelper', array('label', array('placement' => 'append')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'label_after_checkbox', 'id' => 'dd-terms-agreement')))); } }
/** * Create the attribute elements * * * @param integer $attribute_group_id */ private function createAttributesElements($form, $group_id) { $attributeForm = new Zend_Form_SubForm(); $attributeForm->addElementPrefixPath('Shineisp_Decorator', 'Shineisp/Decorator/', 'decorator'); if (is_numeric($group_id)) { // Get all the elements $elements = ProductsAttributesGroups::getAttributesProfiles($group_id, $this->session->langid); if (!empty($elements[0])) { foreach ($elements as $element) { if (!empty($element['ProductsAttributes'])) { // Check the label $label = !empty($element['ProductsAttributes']['ProductsAttributesData'][0]['label']) ? $element['ProductsAttributes']['ProductsAttributesData'][0]['label'] : $element['ProductsAttributes']['code']; $description = !empty($element['ProductsAttributes']['ProductsAttributesData'][0]['description']) ? $element['ProductsAttributes']['ProductsAttributesData'][0]['description'] : ""; // Create the element $attributeForm->addElement($element['ProductsAttributes']['type'], $element['ProductsAttributes']['code'], array('label' => $label, 'class' => 'form-control', 'decorators' => array('Composite'), 'description' => $description)); if ($element['ProductsAttributes']['is_required']) { $attributeForm->getElement($element['ProductsAttributes']['code'])->setRequired(true); } // Handle the default option items for the dropdown selector if ($element['ProductsAttributes']['type'] == "select") { $data = !empty($element['ProductsAttributes']['defaultvalue']) ? json_decode($element['ProductsAttributes']['defaultvalue'], true) : array(); $attributeForm->getElement($element['ProductsAttributes']['code'])->setAllowEmpty(false)->setRegisterInArrayValidator(false)->setMultiOptions($data); } else { $attributeForm->getElement($element['ProductsAttributes']['code'])->setValue($element['ProductsAttributes']['defaultvalue']); } } } $form->addSubForm($attributeForm, 'attributes'); } } return $form; }