public function init() { // usuario_nome $usuario_nome = new Zend_Form_Element_Text('usuario_nome'); $usuario_nome->setLabel('Nome Completo: '); $usuario_nome->setRequired(); $usuario_nome->addErrorMessages(array(Zend_Validate_NotEmpty::IS_EMPTY => "Campo obrigatório!")); $usuario_nome->setAttribs(array('class' => 'form-control', 'placeholder' => 'Informe seu nome')); $usuario_nome->setDecorators(App_Forms_Decorators::$simpleElementDecorators); // usuario_email $usuario_email = new Zend_Form_Element_Text('usuario_email'); $usuario_email->setLabel('E-mail: '); $usuario_email->addValidator(new App_Validate_UsuarioEmail()); $usuario_email->setRequired(); $usuario_email->addValidator('EmailAddress'); $usuario_email->setAttribs(array('class' => 'form-control', 'placeholder' => 'Informe seu e-mail')); $usuario_email->setDecorators(App_Forms_Decorators::$simpleElementDecorators); // usuario_cep $usuario_cep = new Zend_Form_Element_Text('usuario_cep'); $usuario_cep->setLabel('CEP: '); $usuario_cep->setRequired(); $usuario_cep->addValidator(new App_Validate_Cep()); $usuario_cep->setAttribs(array('class' => 'form-control', 'placeholder' => 'Informe seu CEP')); $usuario_cep->setDecorators(App_Forms_Decorators::$simpleElementDecorators); // usuario_senha $usuario_senha = new Zend_Form_Element_Password("usuario_senha"); $usuario_senha->setLabel("Senha: "); $usuario_senha->setRequired(); $usuario_senha->setAttribs(array('class' => 'form-control', 'placeholder' => 'Informe sua senha')); $usuario_senha->setDecorators(App_Forms_Decorators::$simpleElementDecorators); // usuario_politica_termo $usuario_politica_termo = new Zend_Form_Element_Checkbox('usuario_politica_termo'); $usuario_politica_termo->setLabel(" \n Li e concordo com a \n <a href='' data-toggle='modal' data-target='#modal-politica'>Política de Privacidade</a> e \n <a href='' data-toggle='modal' data-target='#modal-termo'>Termo de Uso</a>.\n "); $usuario_politica_termo->setDecorators(App_Forms_Decorators::$checkboxElementDecorators_termo); //$usuario_politica_termo->addDecorator(); //$usuario_politica_termo->setValue(0); //$usuario_politica_termo->setCheckedValue('') ; $usuario_politica_termo->setUnCheckedValue(''); $usuario_politica_termo->setRequired(); $usuario_politica_termo->addErrorMessage('Você precisa concordar com nossa Pólitica de Privacidade e Termo de Uso'); // captcha $captcha = new Zend_Form_Element_Captcha('captcha', array('label' => 'Informe os careacteres da imagem: ', 'class' => 'form-control', 'captcha' => array('captcha' => 'Image', 'wordLen' => 3, 'timeout' => 300, 'font' => APPLICATION_PATH . '/../public/views/fonts/Exo-SemiBold.ttf', 'imgDir' => APPLICATION_PATH . '/../public/views/captcha/', 'imgUrl' => '/../public/views/captcha/'))); $captcha->removeDecorator('ViewHelper'); $this->addElements(array($usuario_nome, $usuario_email, $usuario_cep, $usuario_senha, $usuario_politica_termo)); parent::init(); $this->getElement('submit')->setLabel('Cadastrar'); }
public function init() { /* Form Elements & Other Definitions Here ... */ $emailAddress = $this->createElement('text', 'emailAddress'); $emailAddress->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('class', 'inp1')->setAttrib('maxlength', '40')->addValidators(array(array('NotEmpty', true, array('messages' => 'Please enter your Email.'))))->addValidator('EmailAddress', false, array('messages' => array(Zend_Validate_EmailAddress::INVALID => 'Please enter a valid Host Name')))->addErrorMessage('Pleaes Enter Valid Email Address')->setValue('')->addFilter('StringToLower')->setRequired(true); $password = $this->createElement('password', 'password'); $password->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('class', 'inp1')->setAttrib('maxlength', '20')->addValidators(array(array('NotEmpty', true, array('messages' => 'Please enter your Password.')), array('StringLength', false, array(6, 20, 'messages' => array(Zend_Validate_StringLength::TOO_SHORT => 'Your password is too short(>6).', Zend_Validate_StringLength::TOO_LONG => 'Your password is too long(<20).')))))->setRequired(true)->setValue(''); $imageCaptcha = new Zend_Captcha_Image(); $imageCaptcha->setWidth(120)->setWordlen(4)->setHeight(50)->setTimeout(900)->setFontSize(20)->setGcFreq(5)->setFont('Fonts/tahoma.ttf')->setImgDir('images/captcha/')->setImgUrl('/images/captcha/')->setDotNoiseLevel(0)->setLineNoiseLevel(0); $captcha = new Zend_Form_Element_Captcha('captcha', array('captcha' => $imageCaptcha)); $captcha->removeDecorator('Label')->removeDecorator('DtDdWrapper')->removeDecorator('HtmlTag')->setAttrib('style', 'position:relative;margin-top:20px')->setRequired(false); $login = $this->createElement('submit', 'login'); $login->setLabel("")->removeDecorator('DtDdWrapper')->setAttrib('class', 'submitBtnLgn login')->setIgnore(true); $InvalidAttempts = $this->createElement('hidden', 'InvalidAttempts'); $InvalidAttempts->removeDecorator('HtmlTag')->removeDecorator('DtDdWrapper')->removeDecorator('Label'); $this->addElements(array($emailAddress, $password, $captcha, $login, $InvalidAttempts)); }
public function init() { $contact = array(); $contact[] = array('key' => 'email', 'value' => ' Email'); $contact[] = array('key' => 'phone', 'value' => ' Phone'); $this->setAttrib('enctype', 'multipart/form-data'); $contactName = $this->createElement('text', 'contactName'); $contactName->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('maxlength', '100')->setAttrib('class', 'input w90 required')->setAttrib('placeholder', 'Contact Name')->addFilters(array('StringTrim'))->addValidators(array(array('NotEmpty', true, array('messages' => ' *Required fields'))))->setValue('')->setRequired(true); $address = $this->createElement('text', 'address'); $address->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('maxlength', '500')->setAttrib('class', 'input w90')->setAttrib('placeholder', 'Address')->addFilters(array('StringTrim'))->addValidators(array(array('NotEmpty', true, array('messages' => ' *Required fields')), array('StringLength', false, array(1, 500, 'messages' => array(Zend_Validate_StringLength::TOO_LONG => 'address is too long(>510).')))))->setValue('')->setRequired(false); $city = $this->createElement('text', 'city'); $city->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('class', 'input w90')->setAttrib('placeholder', 'City')->addFilters(array('StringTrim'))->addValidators(array(array('NotEmpty', true, array('messages' => ' *Required fields'))))->addValidator('StringLength', false, array(1, 100))->setValue('')->setAttrib('maxlength', '100')->setRequired(false); $state = $this->createElement('text', 'state'); $state->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('class', 'uinp1')->addFilters(array('StringTrim'))->addValidators(array(array('NotEmpty', true, array('messages' => ' *Required fields'))))->addValidator('StringLength', false, array(1, 200))->setValue('')->setAttrib('maxlength', '200')->setRequired(false); $country = $this->createElement('text', 'country'); $country->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('class', 'uinp1')->addFilters(array('StringTrim'))->addValidators(array(array('NotEmpty', true, array('messages' => ' *Required fields'))))->addValidator('StringLength', false, array(1, 100))->setValue('')->setAttrib('maxlength', '100')->setRequired(false); $postalCode = $this->createElement('text', 'postalCode'); $postalCode->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('class', 'uinp1')->addFilters(array('StringTrim'))->addValidators(array(array('NotEmpty', true, array('messages' => ' *Required fields'))))->addValidator('StringLength', false, array(1, 10))->setValue('')->setAttrib('maxlength', '10')->setRequired(false); $phone = $this->createElement('text', 'phone'); $phone->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('class', 'input w90')->setAttrib('placeholder', 'Phone')->setAttrib('maxlength', '15')->addFilters(array('StringTrim'))->addValidators(array(array('NotEmpty', true, array('messages' => ' *Required fields'))))->setValue('')->setRequired(false); $emailAddress = $this->createElement('text', 'emailAddress'); $emailAddress->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('maxlength', '40')->setAttrib('class', 'input w90')->setAttrib('placeholder', 'Email')->addValidators(array(array('NotEmpty', true, array('messages' => ' *Required fields')), array('StringLength', false, array(5, 40))))->addValidator('EmailAddress')->addFilters(array('StringTrim'))->setRequired(true); $fax = $this->createElement('text', 'fax'); $fax->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('class', 'uinp1')->setAttrib('maxlength', '15')->addFilters(array('StringTrim'))->addValidators(array(array('NotEmpty', true, array('messages' => ' *Required fields'))))->setValue('')->setRequired(false); $website = $this->createElement('text', 'website'); $website->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('class', 'uinp1')->setAttrib('maxlength', '255')->addFilters(array('StringTrim'))->setValue('')->setRequired(false); $moreinfo = $this->createElement('checkbox', 'moreinfo'); $moreinfo->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('class', 'addcontact')->setRequired(false)->setChecked(false); $comments = $this->createElement('textarea', 'comments'); $comments->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('maxlength', '1000')->setAttrib('rows', '3')->setAttrib('cols', '25')->setAttrib('class', 'input w90 textarea')->addFilters(array('StringTrim'))->addValidators(array(array('NotEmpty', true, array('messages' => ' *Required fields'))))->setRequired(true); $imageCaptcha = new Zend_Captcha_Image(); $imageCaptcha->setWidth(120)->setWordlen(4)->setHeight(50)->setTimeout(900)->setFontSize(20)->setGcFreq(5)->setFont('Fonts/tahoma.ttf')->setImgDir('images/captcha/')->setImgUrl('/images/captcha/')->setDotNoiseLevel(0)->setLineNoiseLevel(0); $captcha = new Zend_Form_Element_Captcha('captcha', array('captcha' => $imageCaptcha)); $captcha->removeDecorator('DtDdWrapper')->removeDecorator('HtmlTag')->setAttrib('class', 'inp1')->setAttrib('style', 'position:relative;float:left; width:200px;'); $contactType = new Zend_Form_Element_Radio('contactType'); $contactType->removeDecorator('Label')->removeDecorator('HtmlTag')->setMultiOptions($contact)->setValue('email')->setSeparator(' ')->setRequired(false); $submit = $this->createElement('button', 'submit'); $submit->removeDecorator('Label')->removeDecorator('DtDdWrapper')->setValue('Submit')->setAttrib('class', 'submitBtn')->setIgnore(true); $type = $this->createElement('hidden', 'type'); $type->removeDecorator('HtmlTag')->removeDecorator('Label'); $this->addElements(array($contactName, $address, $city, $state, $country, $postalCode, $phone, $emailAddress, $fax, $website, $moreinfo, $comments, $contactType, $type, $captcha, $submit)); }
public function init() { $passwordConfirm = new Rdine_Validate_PasswordConfirmation(); $salutionList = array(array('key' => 'Mr', 'value' => 'Mr'), array('key' => 'Ms', 'value' => 'Ms'), array('key' => 'Mrs', 'value' => 'Mrs')); $gengerList = array(array('key' => 'Male', 'value' => 'Male'), array('key' => 'Female', 'value' => 'Female')); $emailAddress = $this->createElement('text', 'emailAddress'); $emailAddress->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('maxlength', '40')->setAttrib('class', 'inp1')->setAttrib('placeholder', 'Email Address*')->addValidators(array(array('NotEmpty', true, array('messages' => 'Please enter your EmailAddress.'))))->addValidator('StringLength', false, array(5, 50))->addValidator('EmailAddress', false, array('messages' => array(Zend_Validate_EmailAddress::INVALID => 'Please enter a valid Host Name')))->addErrorMessage('Pleaes Enter Valid Email Address')->addFilters(array('StringTrim'))->setValue('')->addFilter('StringToLower')->setRequired(true); $password = $this->createElement('password', 'password'); $password->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('maxlength', '20')->setAttrib('class', 'inp1')->setAttrib('placeholder', 'Password*')->addValidators(array($passwordConfirm, array('NotEmpty', true, array('messages' => 'Please enter your Password.')), array('StringLength', false, array(6, 20, 'messages' => array(Zend_Validate_StringLength::TOO_SHORT => 'Your password is too short(>6).', Zend_Validate_StringLength::TOO_LONG => 'Your password is too long(<20).')))))->setRequired(true)->setValue('')->setIgnore(false); $confirmPassword = $this->createElement('password', 'password_confirm'); $confirmPassword->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('maxlength', '20')->setAttrib('class', 'inp1')->setAttrib('placeholder', 'Confirm Password*')->addValidators(array($passwordConfirm, array('NotEmpty', true, array('messages' => 'Please enter confirm Password.'))))->setRequired(true)->setValue('')->setIgnore(false); $salution = $this->createElement('select', 'salution'); $salution->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('class', 'sel2')->addMultiOptions($salutionList)->setRequired(false); $firstName = $this->createElement('text', 'firstName'); $firstName->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('maxlength', '30')->setAttrib('class', 'inp1')->setAttrib('placeholder', 'First Name*')->addFilters(array('StringTrim'))->addValidators(array(array('NotEmpty', true, array('messages' => 'Please enter FirstName.')), array('Alnum')))->setValue('')->setRequired(true); $lastName = $this->createElement('text', 'lastName'); $lastName->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('maxlength', '30')->setAttrib('class', 'inp1')->setAttrib('placeholder', 'Last Name')->addFilters(array('StringTrim'))->addValidators(array(array('StringLength', false, array(0, 30)), array('Alnum')))->setValue('')->setRequired(false); // $gender = $this->createElement('select','gender'); // $gender->removeDecorator('Label') // ->removeDecorator('HtmlTag') // ->setAttrib('class', 'sel2') // ->addMultiOptions($gengerList) // ->setRequired(false); $address = $this->createElement('textarea', 'address', array('rows' => '1', 'cols' => '22')); $address->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('maxlength', '200')->setAttrib('class', 'inp1')->addValidators(array(array('NotEmpty', true, array('messages' => 'Please enter your Address.'))))->addValidator('StringLength', false, array(1, 200, 'messages' => array(Zend_Validate_StringLength::TOO_SHORT => 'address should be minimum 10 charactors', Zend_Validate_StringLength::TOO_LONG => 'address is too long(>200).')))->addFilters(array('StringTrim'))->setValue('')->setRequired(false); // $city = $this->createElement('select', 'city'); // $city->removeDecorator('Label') // ->removeDecorator('HtmlTag') // ->setAttrib('class', 'sel1') // ->addValidators(array // (array('NotEmpty', true, array('messages' => 'Please select City.')))) // ->setRegisterInArrayValidator(false) // ->setRequired(true); // // // $neighborhood = $this->createElement('select','neighborhood'); // $neighborhood->removeDecorator('Label') // ->removeDecorator('HtmlTag') // ->setAttrib('class', 'sel1') // ->addValidators(array // (array('NotEmpty', true, array('messages' => 'Please select Neighborhood.')))) // ->setRegisterInArrayValidator(false) // ->setRequired(true); // // // $region = $this->createElement('select','region'); // $region->removeDecorator('Label') // ->removeDecorator('HtmlTag') // ->setAttrib('class', 'sel1') // ->addValidators(array // (array('NotEmpty', true, array('messages' => 'Please select Region.')))) // ->setRegisterInArrayValidator(false) // ->setRequired(true); // // $state = $this->createElement('select','state'); // $state->removeDecorator('Label') // ->removeDecorator('HtmlTag') // ->setAttrib('class', 'sel1') // ->addValidators(array // (array('NotEmpty', true, array('messages' => 'Please select State.')))) // ->addMultiOptions($stateList) // ->setRequired(true); // // $timezone = $this->createElement('select','timezone'); // $timezone->removeDecorator('label') // ->removeDecorator('HtmlTag') // ->setAttrib('class','sel1') // ->addValidators(array // (array('NotEmpty', true, array('messages' => 'Please select TimeZone.')))) // ->addMultiOptions($timezoneList) // ->setRequired(true); $postalCode = $this->createElement('text', 'postalCode'); $postalCode->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('maxlength', '10')->setAttrib('class', 'inp1')->addFilters(array('StringTrim'))->addValidators(array(array('NotEmpty', true, array('messages' => 'Please enter Zipcode.'))))->setValue('')->setRequired(false); $countryCode = $this->createElement('text', 'countryCode'); $countryCode->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('class', 'inp1')->setAttrib('style', 'width:116px; float:left')->setAttrib('placeholder', 'Code')->addFilters(array('StringTrim'))->setAttrib('placeholder', 'Code')->addValidators(array(array('NotEmpty', true, array('messages' => 'Please select country code.'))))->setValue('')->setAttrib('maxlength', '5')->setRequired(false); $phone = $this->createElement('text', 'phone'); $phone->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('class', 'inp1')->setAttrib('style', 'float:right;')->setAttrib('placeholder', 'Phone*')->setAttrib('maxlength', '15')->addFilters(array('StringTrim'))->addValidators(array(array('NotEmpty', true, array('messages' => 'Please enter Your Phone Number.'))))->addValidator('regex', false, array('pattern' => '/^[0-9 ]+$/', 'messages' => 'Enter a valid Phone Number'))->setValue('')->setRequired(false); $mobile = $this->createElement('text', 'mobile'); $mobile->removeDecorator('Label')->removeDecorator('HtmlTag')->removeDecorator('HtmlTag')->setAttrib('class', 'inp1')->setAttrib('maxlength', '15')->addFilters(array('StringTrim'))->setValue(''); // $favoritefood = $this->createElement('textArea', 'favoritefood'); // $favoritefood->removeDecorator('Label') // ->removeDecorator('HtmlTag') // ->setAttrib('maxlength', '1000') // ->setAttrib('cols', '40') // ->setAttrib('rows', '4') // ->addFilters(array('StringTrim')) // ->setValue(''); // // $favoritemusic = $this->createElement('textArea', 'favoritemusic'); // $favoritemusic->removeDecorator('label') // ->removeDecorator('HtmlTag') // ->setAttrib('cols', '40') // ->setAttrib('rows', '4') // ->setAttrib('maxlength', '1000') // ->addFilters(array('StringTrim')) // ->setvalue('') // ->setrequired(false); $imageCaptcha = new Zend_Captcha_Image(); $imageCaptcha->setWidth(120)->setWordlen(4)->setHeight(50)->setTimeout(900)->setFontSize(20)->setGcFreq(5)->setFont('Fonts/tahoma.ttf')->setImgDir('images/captcha/')->setImgUrl('/images/captcha/')->setDotNoiseLevel(0)->setLineNoiseLevel(0); $captcha = new Zend_Form_Element_Captcha('captcha', array('captcha' => $imageCaptcha)); $captcha->removeDecorator('DtDdWrapper')->removeDecorator('HtmlTag')->setAttrib('style', 'position:relative;margin-top:-10px;width:182px;'); $register = $this->createElement('submit', 'register'); $register->setLabel("Register")->removeDecorator('DtDdWrapper')->setAttrib('class', 'submitBtn')->setIgnore(true); $reset = $this->createElement('reset', 'reset'); $reset->removeDecorator('Label')->removeDecorator('DtDdWrapper')->setLabel("Reset")->setAttrib('class', 'submitBtn')->setIgnore(true); $this->addElements(array($emailAddress, $password, $confirmPassword, $salution, $firstName, $lastName, $address, $postalCode, $phone, $countryCode, $mobile, $register, $reset, $captcha)); }
/** * Строит форму * * @param array $fields Массив данных о полях формы * * @return Zend_Form */ public function buildForm($fields) { $form = Phorm_Form::makeForm(); foreach ($fields as $data) { $fieldname = "field_" . $data["fieldid"]; switch ($data["fieldtype"]) { /** * Однострочное текстовое поле */ case "Text": $field = new Zend_Form_Element_Text($fieldname); // Типы валидаторов if ($data["fieldvalidators"] == "Email") { $field->addValidator("EmailAddress", true, array("messages" => array("emailAddressInvalid" => $this->_translate->_("Неверно указан email"), "emailAddressInvalidHostname" => $this->_translate->_("Неверно указан email"), "emailAddressInvalidMxRecord" => $this->_translate->_("Неверно указан email"), "emailAddressInvalidSegment" => $this->_translate->_("Неверно указан email"), "emailAddressDotAtom" => $this->_translate->_("Неверно указан email"), "emailAddressQuotedString" => $this->_translate->_("Неверно указан email"), "emailAddressInvalidLocalPart" => $this->_translate->_("Неверно указан email"), "emailAddressLengthExceeded" => $this->_translate->_("Неверно указан email"), "emailAddressInvalidFormat" => $this->_translate->_("Неверный формат")))); } elseif ($data["fieldvalidators"] == "Date") { $field->addValidator("Date", true, array("messages" => array("dateInvalid" => $this->_translate->_("Неверная дата"), "dateInvalidDate" => $this->_translate->_("Неверная дата"), "dateFalseFormat" => $this->_translate->_("Неверная дата")))); } elseif ($data["fieldvalidators"] == "Int") { $field->addValidator("Int", true, array("messages" => array("notInt" => $this->_translate->_("Значение должно быть числом"), "intInvalid" => $this->_translate->_("Значение должно быть числом")))); } elseif ($data["fieldvalidators"] == "Hostname") { $field->addValidator("Hostname", true, array("messages" => array("hostnameInvalid" => $this->_translate->_("Неверный адрес"), "hostnameIpAddressNotAllowed" => $this->_translate->_("Неверный адрес"), "hostnameUnknownTld" => $this->_translate->_("Неверный адрес"), "hostnameDashCharacter" => $this->_translate->_("Неверный адрес"), "hostnameInvalidHostnameSchema" => $this->_translate->_("Неверный адрес"), "hostnameUndecipherableTld" => $this->_translate->_("Неверный адрес"), "hostnameInvalidHostname" => $this->_translate->_("Неверный адрес"), "hostnameInvalidLocalName" => $this->_translate->_("Неверный адрес"), "hostnameLocalNameNotAllowed" => $this->_translate->_("Неверный адрес"), "hostnameCannotDecodePunycode" => $this->_translate->_("Неверный адрес")))); } // Если разрешен HTML if ($data["htmlallowed"] == "yes") { $field->addFilter("StringTrim"); } else { $field->addFilter("StripTags"); } break; /** * Многострочное текстовое поле */ /** * Многострочное текстовое поле */ case "Textarea": $field = new Zend_Form_Element_Textarea($fieldname); // Если разрешен HTML if ($data["htmlallowed"] == "yes") { $field->addFilter("StringTrim"); } else { $field->addFilter("StripTags"); } break; /** * Чекбокс */ /** * Чекбокс */ case "Checkbox": $field = new Zend_Form_Element_Checkbox($fieldname); break; /** * Радиоточка */ /** * Радиоточка */ case "Radio": $field = new Zend_Form_Element_Radio($fieldname); break; /** * Список */ /** * Список */ case "Select": $field = new Zend_Form_Element_Select($fieldname); $haystack = array(); $optionsdata = explode("\n", $data["optionsdata"]); foreach ($optionsdata as $k => $v) { $haystack[$k] = trim($v); } $field->addMultiOption("", $this->_translate->_("---Выберите---")); foreach ($haystack as $value) { $field->addMultiOption($value, $value); } $haystack[$this->_translate->_("---Выберите---")] = ""; $field->addValidator("InArray", true, array("haystack" => $haystack, "messages" => array("notInArray" => $this->_translate->_("Не выбрано ни одного значения")))); break; /** * Список с множественным выбором */ /** * Список с множественным выбором */ case "Multiselect": $field = new Zend_Form_Element_Multiselect($fieldname); $haystack = array(); $optionsdata = explode("\n", $data["optionsdata"]); foreach ($optionsdata as $k => $v) { $haystack[$k] = trim($v); } foreach ($optionsdata as $value) { $field->addMultiOption($value, $value); } $field->addValidator("InArray", true, array("haystack" => $haystack, "messages" => array("notInArray" => $this->_translate->_("Не выбрано ни одного значения")))); break; /** * Файл */ /** * Файл */ case "File": $field = new Zend_Form_Element_File($fieldname); if ($data["filestypes"] == "Images") { $field->addValidator("Extension", false, array("extension" => "png,jpg,gif,jpeg,bmp", "messages" => array("fileExtensionFalse" => $this->_translate->_("Файл '%value%' не является изображением")))); } elseif ($data["filestypes"] == "Documents") { $field->addValidator("Extension", false, array("extension" => "doc,xls,odt,docx,xlsx,pdf,txt", "messages" => array("fileExtensionFalse" => $this->_translate->_("Файл '%value%' не является документом")))); } elseif ($data["filestypes"] == "Archives") { $field->addValidator("Extension", false, array("extension" => "zip,rar,7z,gz,tgz", "messages" => array("fileExtensionFalse" => $this->_translate->_("Файл '%value%' не является файловым архивом")))); } //$field -> setDestination($this->paths["html"]."forms/files/"); $field->setValueDisabled(true); break; /** * Refferer */ /** * Refferer */ case "Refferer": $field = new Zend_Form_Element_Hidden($fieldname); if (isset($_SERVER["HTTP_REFERER"])) { $field->setValue($_SERVER["HTTP_REFERER"]); } break; /** * CAPTCHA */ /** * CAPTCHA */ case "Captcha": $captcha = Phorm_Captcha_Image::getCaptcha(); $captcha->setOptions(array("messages" => array("badCaptcha" => $this->_translate->_("Неверно указан код подтверждения"), "missingID" => $this->_translate->_("Неверный идентификатор Captcha")))); $field = new Zend_Form_Element_Captcha($fieldname, array("captcha" => $captcha)); break; default: continue; } // Если поле обязательно для заполнения if ($data["isrequired"] == "yes") { $field->setRequired(true)->addValidator("NotEmpty", true, array("messages" => array("isEmpty" => $this->_translate->_("Не заполнено поле")))); } // Устанавливаем заголовок и описание поля if ($field instanceof Zend_Form_Element_Hidden) { $field->removeDecorator("label")->removeDecorator("HtmlTag"); } else { $field->setLabel($data["fieldname"])->setDescription($data["fieldtxt"]); } $form->addElement($field); } $form->addElement(new Zend_Form_Element_Submit("Send", $this->_translate->_("Отправить"))); $form->setAttrib('enctype', 'multipart/form-data'); return $form; }
public function init() { $stateMapper = new Application_Model_CountrybdMapper(); $states = $stateMapper->fetchAll(); $stateList = array(); $stateList[] = array('key' => '', 'value' => 'Select Country'); foreach ($states as $state) { $stateList[] = array('key' => $state->getId(), 'value' => $state->getDescription()); } $stateList[] = array('key' => 'find', 'value' => 'cant find your Country'); $sourceofrestaurantMapper = new Application_Model_SourceofRestaurantDataMapper(); $sources = $sourceofrestaurantMapper->fetchAll(); $sourceList = array(); $sourceList[] = array('key' => '', 'value' => 'Select Source'); foreach ($sources as $source) { $sourceList[] = array('key' => $source->getId(), 'value' => $source->getDescription()); } $passwordConfirm = new Rdine_Validate_PasswordConfirmation(); // $confirmEmail = new Rdine_Validate_EMailConfirmation(); $emailAddress = $this->createElement('text', 'emailAddress'); $emailAddress->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('class', 'inp1')->setAttrib('maxlength', '40')->setAttrib('title', 'Email Address')->setAttrib('placeholder', 'Email Address*')->addValidator('NotEmpty', true, array('messages' => 'Please enter your EmailAddress.'))->addValidator('EmailAddress', false, array('messages' => array(Zend_Validate_EmailAddress::INVALID => 'Please enter a valid Host Name')))->addErrorMessage('Pleaes Enter Valid Email Address')->addFilters(array('StringTrim'))->setValue('')->addFilter('StringToLower')->setRequired(true); // $confirmEmailAdd = $this->createElement('text', 'confirmEmailAddress'); // $confirmEmailAdd->removeDecorator('Label') // ->removeDecorator('HtmlTag') // ->setAttrib('class','inp1') // ->setAttrib('maxlength', '40') // ->setAttrib('title', 'Confirm Email Address') // ->setAttrib('placeholder', 'Confirm Email Address*') // ->addValidators(array($confirmEmail, // array('NotEmpty', true, array('messages' => 'Please confirm your EmailAddress.')) // )) // ->setValue('') // ->addFilters(array('StringTrim')) // ->addFilter('StringToLower') // ->setRequired(true); $password = $this->createElement('password', 'password'); $password->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('class', 'inp1')->setAttrib('maxlength', '20')->setAttrib('title', 'Password')->setAttrib('placeholder', 'Password*')->addValidators(array($passwordConfirm, array('NotEmpty', true, array('messages' => 'Please enter your Password.')), array('StringLength', false, array(6, 20, 'messages' => array(Zend_Validate_StringLength::TOO_SHORT => 'Your password is too short(>6).', Zend_Validate_StringLength::TOO_LONG => 'Your password is too long(<20).')))))->setRequired(true)->setValue(''); $confirmPassword = $this->createElement('password', 'password_confirm'); $confirmPassword->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('class', 'inp1')->setAttrib('maxlength', '20')->setAttrib('title', 'Confirm Password')->setAttrib('placeholder', 'Confirm Password*')->addValidators(array($passwordConfirm, array('NotEmpty', true, array('messages' => 'Please Confirm your password.'))))->setRequired(true)->setValue(''); $firstName = $this->createElement('text', 'firstName'); $firstName->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('class', 'inp1')->setAttrib('maxlength', '30')->setAttrib('title', 'First Name')->setAttrib('placeholder', 'First Name*')->addFilters(array('StringTrim'))->addValidators(array(array('NotEmpty', true, array('messages' => 'Please enter FirstName.')), array('StringLength', false, array(0, 30))))->setValue('')->setRequired(true); $lastName = $this->createElement('text', 'lastName'); $lastName->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('maxlength', '30')->addFilters(array('StringTrim'))->setAttrib('title', 'Last Name')->setAttrib('placeholder', 'Last Name')->addValidators(array(array('StringLength', false, array(0, 30))))->setAttrib('class', 'inp1')->setValue('')->setRequired(false); $countryCode = $this->createElement('text', 'countryCode'); $countryCode->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('class', 'inp1')->setAttrib('style', 'width:116px; float:left')->setAttrib('readonly', 'readonly')->setAttrib('placeholder', 'Code')->setAttrib('title', 'Country Code')->addFilters(array('StringTrim'))->addValidators(array(array('NotEmpty', true, array('messages' => 'Please select country code.'))))->setValue('')->setAttrib('maxlength', '5')->setRequired(false); $phone = $this->createElement('text', 'phone'); $phone->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('class', 'inp1')->setAttrib('maxlength', '10')->setAttrib('title', 'Phone')->setAttrib('style', 'width:325px; float:right;')->setAttrib('placeholder', 'Phone*')->addFilters(array('StringTrim'))->addValidators(array(array('NotEmpty', true, array('messages' => 'Please enter Your Phone Number.'))))->addValidator('regex', false, array('pattern' => '/^[0-9 ]+$/', 'messages' => 'Enter a valid Phone Number'))->setValue('')->setRequired(false); $rastaurantname = $this->createElement('text', 'restaurantName'); $rastaurantname->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('class', 'inp1')->setAttrib('maxlength', '225')->setAttrib('title', 'Restaurant/Group')->setAttrib('placeholder', 'Restaurant/Group*')->addFilters(array('StringTrim'))->addValidators(array(array('NotEmpty', true, array('messages' => 'Please enter RestaurantName.'))))->setvalue('')->setrequired(true); $resownercountry = $this->createElement('text', 'resownercountry'); $resownercountry->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('class', 'inp1')->setAttrib('maxlength', '30')->setAttrib('title', 'Country')->setAttrib('placeholder', 'Country*')->addFilters(array('StringTrim'))->addValidators(array(array('NotEmpty', true, array('messages' => 'Please enter Country.')), array('StringLength', false, array(0, 30)), array('Alnum')))->setValue('')->setRequired(false); $resownercity = $this->createElement('text', 'resownercity'); $resownercity->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('class', 'inp1')->setAttrib('maxlength', '30')->setAttrib('title', 'City')->setAttrib('placeholder', 'City*')->addFilters(array('StringTrim'))->addValidators(array(array('NotEmpty', true, array('messages' => 'Please enter City.')), array('StringLength', false, array(0, 30))))->setValue('')->setRequired(false); $resownerzipcode = $this->createElement('text', 'resownerzipcode'); $resownerzipcode->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('class', 'inp1')->setAttrib('maxlength', '10')->setAttrib('title', 'Zipcode')->setAttrib('placeholder', 'Zipcode')->addFilters(array('StringTrim'))->addValidators(array(array('NotEmpty', true, array('messages' => 'Please enter Zipcode.')), array('StringLength', false, array(0, 10)), array('Alnum')))->setValue('')->setRequired(false); $region = $this->createElement('select', 'region'); $region->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('class', 'sel1')->setAttrib('title', 'State')->addValidators(array(array('NotEmpty', true, array('messages' => 'Please select Region.'))))->setRegisterInArrayValidator(false)->setRequired(true); $state = $this->createElement('select', 'state'); $state->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('class', 'sel1')->setAttrib('title', 'Country')->addValidators(array(array('NotEmpty', true, array('messages' => 'Please select State.'))))->addMultiOptions($stateList)->setRequired(true); $source = $this->createElement('select', 'source'); $source->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('class', 'sel1')->setAttrib('title', 'How did you hear about us?')->addValidators(array(array('NotEmpty', true, array('messages' => 'Please select source.'))))->addMultiOptions($sourceList)->setRequired(false); $sourcedescription = $this->createElement('textarea', 'sourcedescription'); $sourcedescription->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('maxlength', '5000')->setAttrib('cols', '40')->setAttrib('rows', '4')->setAttrib('class', 'inp1')->setAttrib('title', 'Source Description')->setAttrib('placeholder', 'Would you like to provide more information')->setValue('')->addValidators(array(array('StringLength', false, array(1, 200, 'messages' => array(Zend_Validate_StringLength::TOO_LONG => 'Description is too long(>5000).')))))->setRequired(false); $city = $this->createElement('select', 'city'); $city->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('class', 'sel1')->setAttrib('title', 'City')->addValidators(array(array('NotEmpty', true, array('messages' => 'Please select City.'))))->setRegisterInArrayValidator(false)->setRequired(true); $cantfind = $this->createElement('hidden', 'cantfind'); $cantfind->removeDecorator('HtmlTag')->removeDecorator('Label'); $cantfindcity = $this->createElement('text', 'cantfindcity'); $cantfindcity->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('class', 'inp1')->setAttrib('maxlength', '30')->setAttrib('title', 'Cant Find City')->setAttrib('placeholder', 'Enter Your City')->addValidators(array(array('StringLength', false, array(0, 30))))->setValue('')->setRequired(false); $cantfindstate = $this->createElement('text', 'cantfindstate'); $cantfindstate->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('class', 'inp1')->setAttrib('maxlength', '30')->setAttrib('title', 'Cant Find Country')->setAttrib('placeholder', 'Enter Your Country')->addValidators(array(array('StringLength', false, array(0, 30))))->setValue('')->setRequired(false); $cantfindregion = $this->createElement('text', 'cantfindregion'); $cantfindregion->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('class', 'inp1')->setAttrib('maxlength', '30')->setAttrib('title', 'Cant Find State')->setAttrib('placeholder', 'Enter Your State')->addValidators(array(array('StringLength', false, array(0, 30))))->setValue('')->setRequired(false); $description = $this->createElement('textarea', 'description'); $description->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('maxlength', '5000')->setAttrib('cols', '40')->setAttrib('rows', '4')->setAttrib('class', 'inp1')->setAttrib('title', 'Description')->setAttrib('placeholder', 'Enter your comments')->setValue('')->addValidators(array(array('StringLength', false, array(1, 5000, 'messages' => array(Zend_Validate_StringLength::TOO_LONG => 'Description is too long(>5000).')))))->setRequired(false); $website = $this->createElement('text', 'website'); $website->removeDecorator('Label')->removeDecorator('HtmlTag')->setAttrib('class', 'inp1')->setAttrib('maxlength', '30')->setAttrib('title', 'Website')->setAttrib('placeholder', 'Website')->addValidators(array(array('StringLength', false, array(0, 30))))->setValue('')->setRequired(false); $dateofbirth = $this->createElement('text', 'dateofbirth'); $dateofbirth->removeDecorator('Label')->setAttrib('class', 'inp1 datepicker')->removeDecorator('HtmlTag')->setAttrib('title', 'Date of Birth')->setAttrib('placeholder', 'Date of Birth')->addFilters(array('StringTrim'))->setValue(''); $imageCaptcha = new Zend_Captcha_Image(); $imageCaptcha->setWidth(200)->setWordlen(4)->setHeight(50)->setTimeout(900)->setFontSize(20)->setGcFreq(5)->setFont('Fonts/tahoma.ttf')->setImgDir('images/captcha/')->setImgUrl('/images/captcha/')->setDotNoiseLevel(0)->setLineNoiseLevel(0); $captcha = new Zend_Form_Element_Captcha('captcha', array('captcha' => $imageCaptcha)); $captcha->removeDecorator('DtDdWrapper')->removeDecorator('HtmlTag')->setAttrib('title', 'Captcha')->setAttrib('placeholder', 'Enter characters as shown in box *')->setAttrib('style', 'position:relative;margin-top:-10px;width:182px;'); $register = $this->createElement('submit', 'register'); $register->setLabel("Register")->removeDecorator('DtDdWrapper')->setAttrib('class', 'submitBtn')->setIgnore(true); $reset = $this->createElement('reset', 'reset'); $reset->removeDecorator('Label')->removeDecorator('DtDdWrapper')->setLabel("Reset")->setAttrib('class', 'submitBtn')->setIgnore(true); $comapnyid = $this->createElement('hidden', 'comapnyid'); $comapnyid->removeDecorator('HtmlTag')->removeDecorator('Label')->removeDecorator('DtDdWrapper'); $this->addElements(array($firstName, $lastName, $emailAddress, $password, $confirmPassword, $rastaurantname, $description, $phone, $source, $sourcedescription, $website, $dateofbirth, $register, $reset, $captcha, $comapnyid, $countryCode, $resownercity, $resownerzipcode)); }
function setForm() { $form = new Zend_Form; $form->setMethod('post')->setAction(''); $comment_name = new Zend_Form_Element_Text('comment_name'); $comment_name->setRequired(true)->addValidator('NotEmpty',true,array('messages'=>'Vui lòng nhập tên người gửi !')); $comment_name->setAttrib('class','n'); $comment_name->setAttrib("onfocus","if (this.value == 'Nhập tên của bạn') {this.value = '';}"); $comment_name->setAttrib("onblur","if (this.value == '') {this.value = 'Nhập tên của bạn';}"); $comment_name->setValue("Nhập tên của bạn"); $comment_email = new Zend_Form_Element_Text('comment_email'); $comment_email->addValidator('EmailAddress',true,array('messages'=>'Địa chỉ email không hợp lệ')); $comment_email->setRequired(true)->addValidator('NotEmpty',true,array('messages'=>'Vui lòng nhập địa chỉ email !')); $comment_email->setAttrib('class','e'); $comment_email->setAttrib('onfocus',"if (this.value == 'Nhập địa chỉ email của bạn') {this.value = '';}"); $comment_email->setAttrib('onblur',"if (this.value == '') {this.value = 'Nhập địa chỉ email của bạn';}"); $comment_email->setValue('Nhập địa chỉ email của bạn'); $comment_content = new Zend_Form_Element_Textarea('comment_content'); $comment_content->setRequired(true)->addValidator('NotEmpty',true,array('messages'=>'Vui lòng nhập nội dung bình luận!')); $comment_content->setAttrib('class','m'); $comment_content->setAttrib('onfocus',"if (this.value == 'Nhập nội dung bình luận') {this.value = '';}"); $comment_content->setAttrib('onblur',"if (this.value == '') {this.value = 'Nhập nội dung bình luận';}"); $comment_content->setValue('Nhập nội dung bình luận'); $comment_captcha = new Zend_Form_Element_Captcha('comment_captcha',array( 'label' => 'Captcha_image', 'captcha' => array( 'captcha' => 'Image', 'wordLen' => 6, 'timeout' => 300, 'font' => APPLICATION_PATH.'/templates/front/fonts/tiennd.TTF', 'imgDir' => APPLICATION_PATH.'/templates/front/captcha/', 'imgUrl' => $this->view->baseUrl().'/application/templates/front/captcha/', 'height' => 100, 'width' => 200, 'fontSize' => 50, ), )); $comment_captcha->setAttrib('class','captcha_image1'); $comment_captcha->setAttrib('onfocus',"if (this.value == 'Nhập hình ảnh xác nhận') {this.value = '';}"); $comment_captcha->setAttrib('onblur',"if (this.value == '') {this.value = 'Nhập hình ảnh xác nhận';}"); $comment_captcha->setValue('Nhập hình ảnh xác nhận'); $comment_name->removeDecorator('HtmlTag')->removeDecorator('Label'); $comment_email->removeDecorator('HtmlTag')->removeDecorator('Label'); $comment_content->removeDecorator('HtmlTag')->removeDecorator('Label'); $comment_captcha->removeDecorator('HtmlTag')->removeDecorator('Label'); $form->addElements(array($comment_name,$comment_email,$comment_content,$comment_captcha)); return $form; }