public function getForm($data, $protection = 0) { $elementDecorators = array(array('Label'), array('ViewHelper'), array('Errors')); $form = new Zend_Form(); $form->setAction('/user/registration/first-form/')->setMethod('post'); //firstname field $firstName = new Zend_Form_Element_Text('firstname', array('maxLength' => '30', 'id' => 'name', 'validators' => array(array('stringLength', false, array(3, 100)), array('Alpha')))); if (isset($data['u_name'])) { $firstName->setValue($data['u_name']); } if ($protection) { $firstName->setAttrib('readonly', 'true'); } $firstName->setDecorators($elementDecorators); //lastname field $lastName = new Zend_Form_Element_Text('lastname', array('maxLength' => '30', 'id' => 'lname', 'validators' => array(array('stringLength', false, array(3, 100)), array('Alpha')))); $lastName->setDecorators($elementDecorators); if (isset($data['u_family_name'])) { $lastName->setValue($data['u_family_name']); } if ($protection) { $lastName->setAttrib('readonly', 'true'); } //selecting gender: Male (1) or Female (0) $gender = new Zend_Form_Element_Radio('sex', array('separator' => '', 'multiOptions' => array('1' => 'זכר ', '0' => 'נקבה'))); $gender->setDecorators($elementDecorators); $gender->setValue($data['u_sex_id']); if (isset($data['u_sex_id'])) { $gender->setValue($data['u_sex_id']); } if ($protection) { $gender->setAttrib('readonly', 'true'); } //birthday field: validation for yyyy-mm-dd input $birthday = new Zend_Form_Element_Text('datepicker', array('size' => 10)); $birthday->setDecorators($elementDecorators); if (isset($data['u_date_of_birth'])) { $birthday->setValue(date("d/m/Y", strtotime($data['u_date_of_birth']))); } if ($protection) { $birthday->setAttrib('readonly', 'true'); } //heigth $heigth = new Zend_Form_Element_Select('heigth', array()); for ($i = 120; $i <= 300; $i++) { $heigth->addMultiOption($i, $i); } $heigth->setDecorators($elementDecorators); if (isset($data['uht_height'])) { $heigth->setValue($data['uht_height']); } if ($protection) { $heigth->setAttrib('disabled', 'true'); } //weight $weight = new Zend_Form_Element_Select('weight', array('label' => '')); for ($i = 20; $i <= 300; $i++) { $weight->addMultiOption($i, $i); } $weight->setDecorators($elementDecorators); if (isset($data['uht_weight'])) { $weight->setValue($data['uht_weight']); } //email field with validation $email = new Zend_Form_Element_Text('email', array()); $email->addValidator(new Zend_Validate_EmailAddress()); $email->setDecorators($elementDecorators); if (isset($data['u_email'])) { $email->setValue($data['u_email']); } if ($protection) { $email->setAttrib('readonly', 'true'); } // password field $password1 = new Zend_Form_Element_Password('password1', array('id' => 'pass')); $password1->setDecorators($elementDecorators); // password confirmation field $password2 = new Zend_Form_Element_Password('password2', array('id' => 'c_pass')); $password2->addValidator(new User_Form_UserFirstFormPasswordValidator('password1')); $password2->setDecorators($elementDecorators); $state = new Zend_Form_Element_Select('state', array('requred' => true)); $state->setMultiOptions(array('1' => 'מדינה:')); $state->setDecorators($elementDecorators); if (isset($data['u_state'])) { $state->setValue($data['u_state']); } $address = new Zend_Form_Element_Text('address', array('required' => false, 'id' => 'full_adr')); $address->setDecorators($elementDecorators); if (isset($data['u_address'])) { $address->setValue($data['u_address']); } $pregnant = new Zend_Form_Element_Radio('pregnant', array('separator' => '', 'multioptions' => array('Yes' => 'לא', 'No' => 'כן'))); $pregnant->setDecorators($elementDecorators); if ($data['uht_pregnant']) { $pregnant->setValue($data['uht_pregnant']); } $pregnantSince = new Zend_Form_Element_Select('pregnantsince', array('id' => 'hz1')); $pregnantSince->setMultiOptions(array('1' => '1', '2' => '2', '3' => '3', '4' => '4', '5' => '5', '6' => '6', '7' => '7', '8' => '8', '9' => '9')); $pregnantSince->setDecorators($elementDecorators); if ($data['uht_pregnant']) { $pregnant->setValue($data['uht_pregnant']); } if ($data['uht_pregnant_since']) { $pregnantSince->setValue($data['uht_pregnant_since']); } $objectives = new Zend_Form_Element_Textarea('objectives', array('id' => 'obj', 'rows' => '20', 'cols' => '20')); if ($data['u_objectives']) { $objectives->setValue($data['u_objectives']); } $terms = new Zend_Form_Element_Checkbox('terms', array('required' => 'true,')); $heartPressure = new Zend_Form_Element_Checkbox('heartpressure', array()); $heartPressure->setDecorators($elementDecorators); if ($data['uht_heart_or_pb']) { $heartPressure->setChecked(true); } $diabetes = new Zend_Form_Element_Checkbox('diabetes', array()); $diabetes->setDecorators($elementDecorators); if ($data['uht_diabetes']) { $diabetes->setChecked(true); } $migrene = new Zend_Form_Element_Checkbox('migrene', array()); $migrene->setDecorators($elementDecorators); if ($data['uht_migrene']) { $migrene->setChecked(true); } $babies = new Zend_Form_Element_Checkbox('babies', array()); $babies->setDecorators($elementDecorators); if ($data['uht_babies']) { $babies->setChecked(true); } $nosleep = new Zend_Form_Element_Checkbox('nosleep', array()); $nosleep->setDecorators($elementDecorators); if ($data['uht_nosleep']) { $nosleep->setChecked(true); } $digestion = new Zend_Form_Element_Checkbox('digestion', array()); $digestion->setDecorators($elementDecorators); if ($data['uht_digestion']) { $digestion->setChecked(true); } $menopause = new Zend_Form_Element_Checkbox('menopause', array()); $menopause->setDecorators($elementDecorators); if ($data['uht_menopause']) { $menopause->setChecked(true); } $sclorosies = new Zend_Form_Element_Checkbox('sclorosies', array()); $sclorosies->setDecorators($elementDecorators); if ($data['uht_sclorosies']) { $sclorosies->setChecked(true); } $epilepsy = new Zend_Form_Element_Checkbox('epilepsy', array()); $epilepsy->setDecorators($elementDecorators); if ($data['uht_epilepsy']) { $epilepsy->setChecked(true); } $cancer = new Zend_Form_Element_Checkbox('cancer', array()); $cancer->setDecorators($elementDecorators); if ($data['uht_cancer']) { $cancer->setChecked(true); } $asthma = new Zend_Form_Element_Checkbox('asthma', array()); $asthma->setDecorators($elementDecorators); if ($data['uht_asthma']) { $asthma->setChecked(true); } $artritis = new Zend_Form_Element_Checkbox('artritis', array()); $artritis->setDecorators($elementDecorators); if ($data['uht_Artritis']) { $artritis->setChecked(true); } $hernia = new Zend_Form_Element_Checkbox('hernia', array()); $hernia->setDecorators($elementDecorators); if ($data['uht_hernia']) { $hernia->setChecked(true); } $depression = new Zend_Form_Element_Checkbox('depression', array()); $depression->setDecorators($elementDecorators); if ($data['uht_depression_or_anxiety']) { $depression->setChecked(true); } $headaches = new Zend_Form_Element_Checkbox('headaches', array()); $headaches->setDecorators($elementDecorators); if ($data['uht_headaches']) { $headaches->setChecked(true); } $fatigue = new Zend_Form_Element_Checkbox('fatigue', array()); $fatigue->setDecorators($elementDecorators); if ($data['uht_fatigue']) { $fatigue->setChecked(true); } $injury = new Zend_Form_Element_Checkbox('injury', array()); $injury->setDecorators($elementDecorators); if ($data['uht_injury']) { $injury->setChecked(true); } $injuryText = new Zend_Form_Element_Textarea('injurytext', array('id' => 'obj', 'rows' => '20', 'cols' => '20')); if ($data['uht_injury_text']) { $injuryText->setValue($data['uht_injury_text']); } $medication = new Zend_Form_Element_Checkbox('medication', array()); $medication->setDecorators($elementDecorators); if ($data['uht_medication']) { $medication->setChecked(true); } $medicationText = new Zend_Form_Element_Textarea('medicationtext', array('id' => 'obj', 'rows' => '20', 'cols' => '20')); if ($data['uht_which_medication']) { $medicationText->setValue($data['uht_which_medication']); } $walk = new Zend_Form_Element_Radio('walk', array('label' => '', 'separator' => '', 'multiOptions' => array('Yes' => 'כן', 'No' => 'לא'))); if ($data['uht_walk']) { $walk->setValue($data['uht_walk']); } $walk->setDecorators($elementDecorators); $hands = new Zend_Form_Element_Radio('hands', array('label' => '', 'separator' => '', 'multiOptions' => array('Yes' => 'כן', 'No' => 'לא'))); if ($data['uht_hands']) { $hands->setValue($data['uht_hands']); } $hands->setDecorators($elementDecorators); $legs = new Zend_Form_Element_Radio('legs', array('label' => '', 'separator' => '', 'multiOptions' => array('Yes' => 'כן', 'No' => 'לא'))); if ($data['uht_sit']) { $legs->setValue($data['uht_sit']); } $legs->setDecorators($elementDecorators); $backashes = new Zend_Form_Element_Radio('backashes', array('label' => '', 'separator' => '', 'multiOptions' => array('Yes' => 'כן', 'No' => 'לא'))); if ($data['uht_backashes']) { $backashes->setValue($data['uht_backashes']); } $backashes->setDecorators($elementDecorators); if ($protection) { $backashes->setAttrib('disabled', 'true'); } $slippedDisk = new Zend_Form_Element_Radio('disc', array('label' => '', 'separator' => '', 'multiOptions' => array('Yes' => 'כן', 'No' => 'לא'))); if ($protection) { $slippedDisk->setAttrib('disabled', 'true'); } if ($data['uht_slipped_disk']) { $slippedDisk->setValue($data['uht_slipped_disk']); } $slippedDisk->setDecorators($elementDecorators); $generalQuestionsText1 = new Zend_Form_Element_Text('general1', array('id' => 'f_1')); $generalQuestionsText2 = new Zend_Form_Element_Text('general2', array('id' => 'f_2')); $generalQuestionsText3 = new Zend_Form_Element_Text('general3', array('id' => 'f_3')); $generalQuestionsText1->setDecorators($elementDecorators); if ($protection) { $generalQuestionsText1->setAttrib('readonly', 'true'); $generalQuestionsText2->setAttrib('readonly', 'true'); $generalQuestionsText3->setAttrib('readonly', 'true'); } $generalQuestionsText2->setDecorators($elementDecorators); $generalQuestionsText3->setDecorators($elementDecorators); if (isset($data['uht_general1'])) { $generalQuestionsText1->setValue($data['uht_general1']); } if (isset($data['uht_general2'])) { $generalQuestionsText2->setValue($data['uht_general2']); } if (isset($data['uht_general3'])) { $generalQuestionsText3->setValue($data['uht_general3']); } $lowerback = new Zend_Form_Element_Checkbox('lowerback', array()); $lowerback->setDecorators($elementDecorators); if ($data['uht_lower_back']) { $lowerback->setChecked(true); } $upperback = new Zend_Form_Element_Checkbox('upperback', array()); $upperback->setDecorators($elementDecorators); if ($data['uht_upper_back']) { $upperback->setChecked(true); } $feet = new Zend_Form_Element_Checkbox('feet', array()); $feet->setDecorators($elementDecorators); if ($data['uht_ankles_and_feet']) { $feet->setChecked(true); } $neck = new Zend_Form_Element_Checkbox('neck', array()); $neck->setDecorators($elementDecorators); if ($data['uht_neck_and_shoulders']) { $neck->setChecked(true); } $breath = new Zend_Form_Element_Checkbox('breath', array()); $breath->setDecorators($elementDecorators); if ($data['uht_breath']) { $breath->setChecked(true); } $pelvis = new Zend_Form_Element_Checkbox('pelvis', array()); $pelvis->setDecorators($elementDecorators); if ($data['uht_thighs_or_pelvis']) { $pelvis->setChecked(true); } $knees = new Zend_Form_Element_Checkbox('knees', array()); $knees->setDecorators($elementDecorators); if ($data['uht_thighs_or_pelvis']) { $knees->setChecked(true); } $wrists = new Zend_Form_Element_Checkbox('wrists', array()); $wrists->setDecorators($elementDecorators); if ($data['uht_wrists']) { $wrists->setChecked(true); } $head = new Zend_Form_Element_Checkbox('head', array()); $head->setDecorators($elementDecorators); if ($data['uht_head']) { $head->setChecked(true); } $ankles = new Zend_Form_Element_Checkbox('ankles', array()); $ankles->setDecorators($elementDecorators); if ($data['uht_ankles']) { $ankles->setChecked(true); } $externalMails = new Zend_Form_Element_Checkbox('external', array()); $externalMails->setDecorators($elementDecorators); if ($data['u_external_emails']) { $externalMails->setChecked(true); } $moreInfo = new Zend_Form_Element_Textarea('moreinfo', array('id' => 'obj', 'rows' => '20', 'cols' => '20')); if ($data['uht_more_info']) { $moreInfo->setValue($data['uht_more_info']); } $form->addElements(array($firstName, $lastName, $gender, $birthday, $heigth, $weight, $email, $password1, $password2, $state, $address, $pregnant, $pregnantSince, $objectives, $terms, $heartPressure, $diabetes, $migrene, $babies, $nosleep, $digestion, $menopause, $sclorosies, $epilepsy, $cancer, $asthma, $artritis, $hernia, $depression, $fatigue, $headaches, $injury, $injuryText, $medication, $medicationText, $walk, $hands, $legs, $backashes, $slippedDisk, $generalQuestionsText1, $generalQuestionsText2, $generalQuestionsText3, $lowerback, $upperback, $feet, $neck, $breath, $pelvis, $knees, $wrists, $head, $ankles, $moreInfo, $externalMails)); return $form; }
public function testPrepareRenderingAsView() { $form = $this->form; // Elemente hinzufügen, ein leeres, ein nicht leeres $form->addElement(new Zend_Form_Element_Text('textempty')); $element = new Zend_Form_Element_Textarea('textareaempty'); $element->setValue(' '); // leerer String $form->addElement($element); $element = new Zend_Form_Element_Text('textfull'); $element->setValue('Mit Text'); $form->addElement($element); $form->addElement(new Zend_Form_Element_Checkbox('checkboxfalse')); // wird entfernt $element = new Zend_Form_Element_Checkbox('checkboxtrue'); // wird nicht entfernt $element->setChecked(true); $form->addElement($element); $form->addElement(new Zend_Form_Element_Submit('save')); // wird entfernt $form->addElement(new Zend_Form_Element_Button('cancel')); // wird entfernt $element = new Zend_Form_Element_Select('select'); $element->addMultiOption('option1'); $element->setValue('option1'); $form->addElement($element); // wird nicht entfernt // Unterformulare hinzufügen, ein leeres, ein nicht leeres $subform = $this->getForm(); // Leeres Unterformular $form->addSubForm($subform, 'subformempty'); $subform2 = $this->getForm(); // Nicht leeres Unterformular $element = new Zend_Form_Element_Text('subformtextfull'); $element->setValue('Im SubForm mit Text'); $subform2->addElement($element); $form->addSubForm($subform2, 'subformnotempty'); $form->prepareRenderingAsView(); $this->assertTrue($form->isViewModeEnabled()); $this->assertEquals(3, count($form->getElements())); // Leere Elemente wurden entfernt $this->assertArrayHasKey('textfull', $form->getElements()); $this->assertArrayHasKey('checkboxtrue', $form->getElements()); $this->assertArrayHasKey('select', $form->getElements()); $this->assertEquals(1, count($form->getSubForms())); // Leeres Unterformular wurde entfernt $this->assertArrayHasKey('subformnotempty', $form->getSubForms()); // Decorators ueberpruefen $decorators = $form->getElement('textfull')->getDecorators(); $this->assertEquals(5, count($decorators)); $this->assertArrayHasKey('Application_Form_Decorator_ViewHelper', $decorators); $this->assertTrue($form->getElement('textfull')->getDecorator('ViewHelper')->isViewOnlyEnabled()); $decorators = $form->getElement('checkboxtrue')->getDecorators(); $this->assertEquals(5, count($decorators)); $this->assertArrayHasKey('Application_Form_Decorator_ViewHelper', $decorators); $this->assertTrue($form->getElement('checkboxtrue')->getDecorator('ViewHelper')->isViewOnlyEnabled()); $decorators = $form->getElement('select')->getDecorators(); $this->assertEquals(5, count($decorators)); $this->assertArrayHasKey('Application_Form_Decorator_ViewHelper', $decorators); $this->assertTrue($form->getElement('select')->getDecorator('ViewHelper')->isViewOnlyEnabled()); }
public function startForm($p_blockId, $p_isValid = false) { // load type $out = CcBlockQuery::create()->findPk($p_blockId); if ($out->getDbType() == "static") { $blockType = 0; } else { $blockType = 1; } $spType = new Zend_Form_Element_Radio('sp_type'); $spType->setLabel(_('Set smart block type:'))->setDecorators(array('viewHelper'))->setMultiOptions(array('static' => _('Static'), 'dynamic' => _('Dynamic')))->setValue($blockType); $this->addElement($spType); $bl = new Application_Model_Block($p_blockId); $storedCrit = $bl->getCriteria(); //need to convert criteria to be displayed in the user's timezone if there's some timestamp type. self::convertTimestamps($storedCrit["crit"]); /* $modRoadMap stores the number of same criteria * Ex: 3 Album titles, and 2 Track titles * We need to know this so we display the form elements properly */ $modRowMap = array(); $openSmartBlockOption = false; if (!empty($storedCrit)) { $openSmartBlockOption = true; } $criteriaKeys = array(); if (isset($storedCrit["crit"])) { $criteriaKeys = array_keys($storedCrit["crit"]); } $numElements = count($this->getCriteriaOptions()); for ($i = 0; $i < $numElements; $i++) { $criteriaType = ""; if (isset($criteriaKeys[$i])) { $critCount = count($storedCrit["crit"][$criteriaKeys[$i]]); } else { $critCount = 1; } $modRowMap[$i] = $critCount; /* Loop through all criteria with the same field * Ex: all criteria for 'Album' */ for ($j = 0; $j < $critCount; $j++) { /****************** CRITERIA ***********/ if ($j > 0) { $invisible = ' sp-invisible'; } else { $invisible = ''; } $criteria = new Zend_Form_Element_Select("sp_criteria_field_" . $i . "_" . $j); $criteria->setAttrib('class', 'input_select sp_input_select' . $invisible)->setValue('Select criteria')->setDecorators(array('viewHelper'))->setMultiOptions($this->getCriteriaOptions()); if ($i != 0 && !isset($criteriaKeys[$i])) { $criteria->setAttrib('disabled', 'disabled'); } if (isset($criteriaKeys[$i])) { $criteriaType = $this->criteriaTypes[$storedCrit["crit"][$criteriaKeys[$i]][$j]["criteria"]]; $criteria->setValue($storedCrit["crit"][$criteriaKeys[$i]][$j]["criteria"]); } $this->addElement($criteria); /****************** MODIFIER ***********/ $criteriaModifers = new Zend_Form_Element_Select("sp_criteria_modifier_" . $i . "_" . $j); $criteriaModifers->setValue('Select modifier')->setAttrib('class', 'input_select sp_input_select')->setDecorators(array('viewHelper')); if ($i != 0 && !isset($criteriaKeys[$i])) { $criteriaModifers->setAttrib('disabled', 'disabled'); } if (isset($criteriaKeys[$i])) { if ($criteriaType == "s") { $criteriaModifers->setMultiOptions($this->getStringCriteriaOptions()); } else { $criteriaModifers->setMultiOptions($this->getNumericCriteriaOptions()); } $criteriaModifers->setValue($storedCrit["crit"][$criteriaKeys[$i]][$j]["modifier"]); } else { $criteriaModifers->setMultiOptions(array('0' => _('Select modifier'))); } $this->addElement($criteriaModifers); /****************** VALUE ***********/ $criteriaValue = new Zend_Form_Element_Text("sp_criteria_value_" . $i . "_" . $j); $criteriaValue->setAttrib('class', 'input_text sp_input_text')->setDecorators(array('viewHelper')); if ($i != 0 && !isset($criteriaKeys[$i])) { $criteriaValue->setAttrib('disabled', 'disabled'); } if (isset($criteriaKeys[$i])) { $criteriaValue->setValue($storedCrit["crit"][$criteriaKeys[$i]][$j]["value"]); } $this->addElement($criteriaValue); /****************** EXTRA ***********/ $criteriaExtra = new Zend_Form_Element_Text("sp_criteria_extra_" . $i . "_" . $j); $criteriaExtra->setAttrib('class', 'input_text sp_extra_input_text')->setDecorators(array('viewHelper')); if (isset($criteriaKeys[$i]) && isset($storedCrit["crit"][$criteriaKeys[$i]][$j]["extra"])) { $criteriaExtra->setValue($storedCrit["crit"][$criteriaKeys[$i]][$j]["extra"]); $criteriaValue->setAttrib('class', 'input_text sp_extra_input_text'); } else { $criteriaExtra->setAttrib('disabled', 'disabled'); } $this->addElement($criteriaExtra); } //for } //for $repeatTracks = new Zend_Form_Element_Checkbox('sp_repeat_tracks'); $repeatTracks->setDecorators(array('viewHelper'))->setLabel(_('Allow Repeat Tracks:')); if (isset($storedCrit["repeat_tracks"])) { $repeatTracks->setChecked($storedCrit["repeat_tracks"]["value"] == 1 ? true : false); } $this->addElement($repeatTracks); $limit = new Zend_Form_Element_Select('sp_limit_options'); $limit->setAttrib('class', 'sp_input_select')->setDecorators(array('viewHelper'))->setMultiOptions($this->getLimitOptions()); if (isset($storedCrit["limit"])) { $limit->setValue($storedCrit["limit"]["modifier"]); } $this->addElement($limit); $limitValue = new Zend_Form_Element_Text('sp_limit_value'); $limitValue->setAttrib('class', 'sp_input_text_limit')->setLabel(_('Limit to'))->setDecorators(array('viewHelper')); $this->addElement($limitValue); if (isset($storedCrit["limit"])) { $limitValue->setValue($storedCrit["limit"]["value"]); } else { // setting default to 1 hour $limitValue->setValue(1); } //getting block content candidate count that meets criteria $bl = new Application_Model_Block($p_blockId); if ($p_isValid) { $files = $bl->getListofFilesMeetCriteria(); $showPoolCount = true; } else { $files = null; $showPoolCount = false; } $generate = new Zend_Form_Element_Button('generate_button'); $generate->setAttrib('class', 'btn btn-small'); $generate->setAttrib('title', _('Generate playlist content and save criteria')); $generate->setIgnore(true); $generate->setLabel(_('Generate')); $generate->setDecorators(array('viewHelper')); $this->addElement($generate); $shuffle = new Zend_Form_Element_Button('shuffle_button'); $shuffle->setAttrib('class', 'btn btn-small'); $shuffle->setAttrib('title', _('Shuffle playlist content')); $shuffle->setIgnore(true); $shuffle->setLabel(_('Shuffle')); $shuffle->setDecorators(array('viewHelper')); $this->addElement($shuffle); $this->setDecorators(array(array('ViewScript', array('viewScript' => 'form/smart-block-criteria.phtml', "openOption" => $openSmartBlockOption, 'criteriasLength' => count($this->getCriteriaOptions()), 'poolCount' => $files['count'], 'modRowMap' => $modRowMap, 'showPoolCount' => $showPoolCount)))); }
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')))); } }
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'); // $addressParams = array( // "fieldsValue" => array(), // "display" => array(), // "required" => array(), // ); // Salutation $salutation = new Zend_Form_Element_Select('salutation'); $salutation->setLabel($this->getView()->getCibleText('form_label_salutation'))->setAttrib('class', 'smallSelect')->setAttrib('tabindex', '1')->setOrder(1); $greetings = $this->getView()->getAllSalutation(); foreach ($greetings as $greeting) { $salutation->addMultiOption($greeting['S_ID'], $greeting['ST_Value']); } // Language $languages = new Zend_Form_Element_Select('language'); $languages->setLabel($this->getView()->getCibleText('form_label_language'))->setAttrib('class', 'stdSelect')->setAttrib('tabindex', '9')->setOrder(9); foreach (Cible_FunctionsGeneral::getAllLanguage() as $lang) { $languages->addMultiOption($lang['L_ID'], $lang['L_Title']); } // 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'))->setAttrib('tabindex', '2')->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'))->setAttrib('tabindex', '3')->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'))->setAttrib('tabindex', '5')->setOrder(5); 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')->setAttrib('tabindex', '6')->setRequired(true)->setOrder(6)->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_confirmPwd')); } // $passwordConfirmation->setLabel($this->getView()->getCibleText('form_label_confirmNewPwd')); $passwordConfirmation->addFilter('StripTags')->addFilter('StringTrim')->setRequired(true)->setOrder(7)->setAttrib('class', 'stdTextInput')->setAttrib('tabindex', '7')->setDecorators(array('ViewHelper', array(array('row' => 'HtmlTag'), array('tag' => 'dd')), array('label', array('class' => 'test', 'tag' => 'dt', 'tagClass' => 'alignVertical')))); 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)->setAttrib('tabindex', '4')->setOrder(4)->setAttribs(array('class' => 'stdTextInput')); // Account number $account = new Zend_Form_Element_Text('accountNum'); $account->setLabel($this->getView()->getCibleText('form_label_account'))->setRequired(true)->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->setOrder(8)->setAttribs(array('class' => 'stdTextInput'))->setAttrib('tabindex', '8')->setDecorators(array('ViewHelper', 'Errors', array(array('row' => 'HtmlTag'), array('tag' => 'dd')), array('label', array('class' => 'test', 'tag' => 'dt', 'tagClass' => 'alignVertical')))); // Text Subscribe $textSubscribe = $this->getView()->getCibleText('form_label_subscribe'); $textSubscribe = str_replace('%URL_PRIVACY_POLICY%', Cible_FunctionsPages::getPageLinkByID($this->_config->privacyPolicy->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', 'id' => 'subscribeNewsletter', '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'); $submitLabel = $this->getView()->getCibleText('form_account_button_submit'); if ($this->_mode == 'edit') { $submitLabel = $this->getView()->getCibleText('button_submit'); } $submit->setLabel($submitLabel)->setAttrib('class', 'stdButton subscribeButton1-' . Zend_Registry::get("languageSuffix")); // Captcha // Refresh button $refresh_captcha = new Zend_Form_Element_Button('refresh_captcha'); $refresh_captcha->setLabel($this->getView()->getCibleText('button_refresh_captcha'))->setAttrib('onclick', "refreshCaptcha('captcha-id')")->setAttrib('class', 'stdButton')->removeDecorator('Label')->removeDecorator('DtDdWrapper'); $refresh_captcha->addDecorators(array(array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'dd-refresh-captcha-button')))); $captcha = new Zend_Form_Element_Captcha('captcha', array('label' => $this->getView()->getCibleText('form_label_securityCaptcha'), 'captcha' => 'Image', 'captchaOptions' => array('captcha' => 'Word', 'wordLen' => 5, 'fontSize' => 28, 'height' => 67, 'width' => 169, 'timeout' => 300, 'dotNoiseLevel' => 0, 'lineNoiseLevel' => 0, 'font' => Zend_Registry::get('application_path') . "/../{$this->_config->document_root}/captcha/fonts/ARIAL.TTF", 'imgDir' => Zend_Registry::get('application_path') . "/../{$this->_config->document_root}/captcha/tmp", 'imgUrl' => "{$baseDir}/captcha/tmp"))); $captcha->setAttrib('class', 'stdTextInputCatcha'); $captcha->setRequired(true); $captcha->addDecorators(array(array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'id' => 'dd_captcha'))))->addDecorator('Label', array('class' => 'clear')); $french = array('badCaptcha' => 'Veuillez saisir la chaîne ci-dessus correctement.'); $english = array('badCaptcha' => 'Captcha value is wrong'); $translate = new Zend_Translate('array', $french, 'fr'); $this->setTranslator($translate); $this->getView()->jQuery()->enable(); $script = <<<EOS function refreshCaptcha(id){ \$.getJSON('{$this->getView()->baseUrl()}/newsletter/index/captcha-reload', function(data){ \$("dd#dd_captcha img").attr({src : data['url']}); \$("#"+id).attr({value: data['id']}); }); } EOS; $this->getView()->headScript()->appendScript($script); // Captcha /* Identification sub form */ $identificationSub = new Cible_Form_SubForm(); $identificationSub->setName('identification')->removeDecorator('DtDdWrapper'); $identificationSub->setLegend($this->getView()->getCibleText('form_account_subform_identification_legend')); $identificationSub->setAttrib('class', 'identificationClass subFormClass'); $identificationSub->addElement($languages); $identificationSub->addElement($salutation); $identificationSub->addElement($lastname); $identificationSub->addElement($firstname); $identificationSub->addElement($email); $identificationSub->addElement($password); $identificationSub->addElement($passwordConfirmation); $identificationSub->addElement($company); $identificationSub->addElement($account); $identificationSub->addDisplayGroup(array('salutation', 'firstName', 'company', 'password', 'accountNum'), 'leftColumn'); $identificationSub->addDisplayGroup(array('lastName', 'email', 'passwordConfirmation', 'language'), 'rightColumn')->removeDecorator('DtDdWrapper'); $leftColGroup = $identificationSub->getDisplayGroup('leftColumn'); $rightColGroup = $identificationSub->getDisplayGroup('rightColumn'); $leftColGroup->removeDecorator('DtDdWrapper'); $rightColGroup->removeDecorator('DtDdWrapper'); $this->addSubForm($identificationSub, 'identification'); // Billing address $addressFacturationSub = new Cible_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->enableFields(array('firstAddress', 'secondAddress', 'cityTxt', 'zipCode', 'country', 'state', 'firstTel', 'secondTel', 'fax')); $billingAddr->formAddress(); $addrBill = new Zend_Form_Element_Hidden('addrBill'); $addrBill->removeDecorator('label'); $addressFacturationSub->addElement($addrBill); $this->addSubForm($addressFacturationSub, 'addressFact'); /* delivery address */ $addrShip = new Zend_Form_Element_Hidden('addrShip'); $addrShip->removeDecorator('label'); $addressShippingSub = new Cible_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); $shipAddr->duplicateAddress($addressShippingSub); $shipAddr->setProperty('addScriptState', false); $shipAddr->enableFields(array('firstAddress', 'secondAddress', 'cityTxt', 'zipCode', 'country', 'state', 'firstTel', 'secondTel', 'fax')); $shipAddr->formAddress(); $addressShippingSub->addElement($addrShip); $this->addSubForm($addressShippingSub, 'addressShipping'); if ($this->_mode == 'add') { $this->getView()->jQuery()->enable(); $script = <<<EOS function refreshCaptcha(id){ \$.getJSON('{$this->getView()->baseUrl()}/order/index/captcha-reload', function(data){ \$("dd#dd_captcha img").attr({src : data['url']}); \$("#"+id).attr({value: data['id']}); }); } EOS; // $this->getView()->headScript()->appendScript($script); // $this->addElement($refresh_captcha); // $this->addElement($captcha); $this->addElement($newsletterSubscription); $this->addElement($termsAgreement); } $this->addElement($submit); $submit->setDecorators(array('ViewHelper', array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'account-submit')))); 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')))); } $captchaError = array('badCaptcha' => $this->getView()->getCibleText('validation_message_captcha_error')); $translate = new Zend_Translate('array', $captchaError, $this->getView()->registryGet('languageSuffix')); $this->setTranslator($translate); }