function setForm() { $form=new Zend_Form; $form->setMethod('post')->setAction(''); $image_name = new Zend_Form_Element_Text('image_name'); $image_name->setRequired(true)->addValidator('NotEmpty',true,array('messages'=>'Tên ảnh không được để trống')); $image_link = new Zend_Form_Element_Textarea('image_link'); $image_link->setRequired(true)->addValidator('NotEmpty',true,array('messages'=>'Hình ảnh không được để trống')); $is_active = new Zend_Form_Element_Radio('is_active'); $is_active->setRequired(true) ->setLabel('is_active') ->setMultiOptions(array("1" => "Có","0" => "Không")); $image_name->removeDecorator('HtmlTag')->removeDecorator('Label'); $image_link->removeDecorator('HtmlTag')->removeDecorator('Label'); $is_active->removeDecorator('HtmlTag')->removeDecorator('Label'); $form->addElements(array($image_name,$image_link,$is_active)); return $form; }
function setForm() { $form = new Zend_Form; $form->setMethod('post')->setAction(''); //$this->setAttrib('enctype','multipart/form-data'); $file = new Zend_Form_Element_File('video_file'); //$file->setAttrib('class','file'); $file->setLabel('video_file'); $file->setRequired(true); $video_title = new Zend_Form_Element_Text('video_title'); $video_title ->setRequired(true)->addValidator('NotEmpty',true,array('messages'=>'Tiêu đề không được để trống')); $video_thumbnail=new Zend_Form_Element_Textarea('video_thumbnail'); $video_thumbnail->removeDecorator('HtmlTag')->removeDecorator('Label'); $video_description = new Zend_Form_Element_Textarea('video_description'); $video_description->setAttrib('rows','7'); $video_description ->setRequired(true)->addValidator('NotEmpty',true,array('messages'=>'Mô tả không được để trống')); $is_active = new Zend_Form_Element_Radio('is_active'); $is_active->setRequired(true) ->setLabel('is_active') ->setMultiOptions(array("1" => "Có","0" => "Không")); $file->removeDecorator('HtmlTag')->removeDecorator('Label'); $video_title->removeDecorator('HtmlTag')->removeDecorator('Label'); $video_description->removeDecorator('HtmlTag')->removeDecorator('Label'); $is_active->removeDecorator('HtmlTag')->removeDecorator('Label'); $form->addElements(array($file,$video_title,$video_description,$is_active,$video_thumbnail)); return $form; }
public function init() { $Ankieta = new Application_Model_DbTable_AnkietyPytania(); $select = $Ankieta->select(array('id', 'pytanie', 'czy_obrazek'))->where('czy_wyswietlac = ?', 't')->where('sekcja = ?', 'lewa')->where('rodzaj = ?', 'normal')->order('kolejnosc DESC')->order('data_dodania DESC')->order('pytanie ASC')->limit(1); //echo $select->__toString(); $ankieda = $Ankieta->fetchAll($select); foreach ($ankieda as $pytanie) { $pytania_id[] = $pytanie->id; $pytania[] = $pytanie->pytanie; $odpowiedziFetch = $pytanie->findApplication_Model_DbTable_AnkietyOdpowiedzi(); // sortowanie $odpowiedziArray = $odpowiedziFetch->toArray(); usort($odpowiedziArray, create_function('$a, $b', 'if ($a["kolejnosc"] == $b["kolejnosc"]) return 0; return ($a["kolejnosc"] < $b["kolejnosc"]) ? -1 : 1;')); // usort($odpowiedziArray, sort_answers($a, $b){ // return strcmp($a["kolejnosc"], $b["kolejnosc"]); // });// sort foreach ($odpowiedziArray as $odpowiedz) { $odpowiedzi_id[] = $odpowiedz['id']; $odpowiedzi[] = $odpowiedz['odpowiedz']; } } $this->addElement('hidden', 'plaintext', array('description' => '<dt id="odpowiedzi-label"><h3 class="tytul">' . $pytania[0] . '</h3></dt>', 'decorators' => array(array('Description', array('escape' => false, 'tag' => ''))))); $kontrolkaRadio = new Zend_Form_Element_Radio("odpowiedzi[]", array('multiOptions' => array_combine($odpowiedzi_id, $odpowiedzi), 'registerInArrayValidator' => false, 'validators' => array('NotEmpty' => array('validator' => 'NotEmpty', 'options' => array('messages' => 'Musisz wybrać jedną odpowiedź.'))))); $kontrolkaRadio->setRequired(true); $kontrolkaRadio->removeDecorator('Label'); $kontrolkaRadio->setSeparator(false); $this->addElement($kontrolkaRadio); if ($ankieda[0]->czy_obrazek == 't') { //first create an image type captcha $captchaimg = new Zend_Captcha_Image('captchaimg'); $captchaimg->setFont(APPLICATION_PATH . '/../public/images/tresci/captcha/Tahoma.ttf'); $captchaimg->setImgDir(APPLICATION_PATH . '/../public/images/tresci/captcha'); $captchaimg->setImgUrl('/images/tresci/captcha'); $captchaimg->setWordlen('5'); $captchaimg->setMessages(array('badCaptcha' => 'Wpisany kod jest nieprawidłowy')); // $captchaimg->generate(); //create user input for captcha and include the captchaimg in form $adcaptcha = new Zend_Form_Element_Captcha('adcaptcha', array('captcha' => $captchaimg)); $adcaptcha->setLabel('Wpisz kod z obrazka:'); $adcaptcha->setRequired(true); $this->addElement($adcaptcha); } $kontrolkaSubmit = new Zend_Form_Element_Submit("submit", "Głosuj"); // $kontrolkaSubmit->removeDecorator('DtDdWrapper'); // $kontrolkaSubmit->setAttribs(array('style' => 'margin-left:130px;')); $kontrolkaSubmit->removeDecorator('Label'); $this->addElement($kontrolkaSubmit); $this->addDecorators(array('FormElements', array('HtmlTag', array('tag' => 'div', 'class' => 'sonda-content')), array('Form', array('class' => 'sonda-form')))); //echo $pytania_id[0]; $this->setMethod('post'); //$url = $view->url(array('controller' => 'sonda', 'action' => 'edit', 'id' => $pytania_id[0]), 'default'); $url = $this->getView()->url(array('controller' => 'sonda', 'action' => 'edit', 'id' => $pytania_id[0]), 'default'); $this->setAction($url); }
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)); }
function setForm() { $form=new Zend_Form; $form->setMethod('post')->setAction(''); $category_name = new Zend_Form_Element_Text('category_name'); $category_name->setRequired(true)->addValidator('NotEmpty',true,array('messages'=>'Tên chuyên mục không được để trống')); $is_active= new Zend_Form_Element_Radio('is_active'); $is_active->setRequired(true) ->setLabel('Are you sure?') ->setMultiOptions(array( "1" => "Có", "0" => "Không")); $category_name->removeDecorator('HtmlTag')->removeDecorator('Label'); $is_active->removeDecorator('HtmlTag')->removeDecorator('Label'); $form->addElements(array($category_name,$is_active)); return $form; }
function setForm() { $form=new Zend_Form; $form->setMethod('post')->setAction(''); $user_login = new Zend_Form_Element_Text('user_login'); $user_login->setRequired(true)->addValidator('NotEmpty',true,array('messages'=>'Tên đăng nhập không được để trống')); $user_pass = new Zend_Form_Element_Password('user_pass'); $user_pass->setAttrib('renderPassword', true); $user_pass->setRequired(true)->addValidator('NotEmpty',true,array('messages'=>'Mật khẩu không được để trống')); $user_fullname = new Zend_Form_Element_Text('user_fullname'); $user_fullname->setRequired(true)->addValidator('NotEmpty',true,array('messages'=>'Tên người dùng không được để trống')); $user_email = new Zend_Form_Element_Text('user_email'); $user_email->addValidator('EmailAddress',true,array('messages'=>'Địa chỉ email không hợp lệ')); $user_email->setRequired(true)->addValidator('NotEmpty',true,array('messages'=>'Email không được để trống')); $user_address = new Zend_Form_Element_Text('user_address'); $user_address->setRequired(true)->addValidator('NotEmpty',true,array('messages'=>'Địa chỉ không được để trống')); $is_active=new Zend_Form_Element_Radio('is_active'); $is_active->setRequired(true) ->setLabel('Is active?') ->setMultiOptions(array( "0" => "Không", "1" => "Có")); $user_login->removeDecorator('HtmlTag')->removeDecorator('Label'); $user_pass->removeDecorator('HtmlTag')->removeDecorator('Label'); $user_fullname->removeDecorator('HtmlTag')->removeDecorator('Label'); $user_email->removeDecorator('HtmlTag')->removeDecorator('Label'); $user_address->removeDecorator('HtmlTag')->removeDecorator('Label'); $is_active->removeDecorator('HtmlTag')->removeDecorator('Label'); $form->addElements(array($user_login,$user_pass,$user_fullname,$user_email,$user_address,$is_active)); return $form; }
function setForm($check,$id) { $form=new Zend_Form; $form->setMethod('post')->setAction(''); $category_name = new Zend_Form_Element_Text('category_name'); $category_name->setRequired(true)->addValidator('NotEmpty',true,array('messages'=>'Tên chuyên mục không được để trống')); $category_parent_id = new Zend_Form_Element_Select('category_parent_id'); $category_parent_id->addMultiOption('0', ''); if($check==1) { $list = $this->mChuyenmuc->getListParentSubOne($id); } else { $list = $this->mChuyenmuc->getListCmParent(); } foreach($list as $item) { $category_parent_id->addMultiOption($item['category_id'],$item['category_name']); } $is_active= new Zend_Form_Element_Radio('is_active'); $is_active->setRequired(true) ->setLabel('Are you sure?') ->setMultiOptions(array( "1" => "Có", "0" => "Không")); $category_name->removeDecorator('HtmlTag')->removeDecorator('Label'); $category_parent_id->removeDecorator('HtmlTag')->removeDecorator('Label'); $is_active->removeDecorator('HtmlTag')->removeDecorator('Label'); $form->addElements(array($category_name,$category_parent_id,$is_active)); return $form; }
function setForm() { $form=new Zend_Form(); $form->setMethod('post'); $form->setName('insertForm'); $form->setAction($this->view->baseUrl().'/admin/tintuc/insert'); $form->addElement('text','news_title'); $news_login=$form->getElement('news_title'); $news_login->setRequired(true)->addValidator('NotEmpty',true,array('messages'=>'Tiêu đề không được để trống'));; $news_login->removeDecorator('HtmlTag')->removeDecorator('Label'); $el=$form->createElement('textarea','news_avatar', array('style'=>'height:100px')); $el->setRequired(true)->addValidator('NotEmpty',true,array('messages'=>'Avatar không được để trống')); $el->setAttrib('id', 'news_avatar'); $el->removeDecorator('HtmlTag')->removeDecorator('Label'); $form->addElement($el); $el=$form->createElement('textarea','news_summary', array('style'=>'height:100px')); $el->setRequired(true)->addValidator('NotEmpty',true,array('messages'=>'Mục tóm tắt không được để trống')); $el->setAttrib('id', 'news_summary'); $el->removeDecorator('HtmlTag')->removeDecorator('Label'); $form->addElement($el); $el=$form->createElement('textarea','news_content', array('style'=>'height:300px')); $el->setRequired(true)->addValidator('NotEmpty',true,array('messages'=>'Nội dung không được để trống'));; $el->setAttrib('id', 'news_content'); $el->removeDecorator('HtmlTag')->removeDecorator('Label'); $form->addElement($el); $form->addElement('text','news_author'); $el=$form->getElement('news_author'); $el->setValue($_SESSION['user']); $el->removeDecorator('HtmlTag')->removeDecorator('Label'); $form->addElement('text','news_post_date'); $el=$form->getElement('news_post_date'); $el->setAttrib('class', 'datepicker'); $el->setValue(date("Y-m-d",time()+7*3600)); $el->removeDecorator('HtmlTag')->removeDecorator('Label'); $form->addElement('text','news_modified_date'); $el=$form->getElement('news_modified_date'); $el->setAttrib('class', 'datepicker'); $el->removeDecorator('HtmlTag')->removeDecorator('Label'); if ($_SESSION['role_id']==0) { $el=$form->createElement('select', 'news_status', array('multioptions'=>array('Chưa duyệt'=>'Chưa duyệt', 'Đã duyệt'=>'Đã duyệt', 'Riêng tư'=>'Riêng tư', 'Công khai'=>'Công khai'))); } else if ($_SESSION['role_id']==1) { $el=$form->createElement('select', 'news_status', array('multioptions'=>array( 'Đã duyệt'=>'Đã duyệt', 'Riêng tư'=>'Riêng tư', 'Công khai'=>'Công khai'))); } else { $el=$form->createElement('select', 'news_status', array('multioptions'=>array( 'Chưa duyệt'=>'Chưa duyệt', 'Đã duyệt'=>'Đã duyệt'))); } $el->removeDecorator('HtmlTag')->removeDecorator('Label'); $form->addElement($el); $is_hot= new Zend_Form_Element_Radio('is_hot'); $is_hot->setRequired(true) ->setLabel('Is hot?') ->setMultiOptions(array( "0" => "Không", "1" => "Có")); $is_hot->removeDecorator('HtmlTag')->removeDecorator('Label'); $form->addElement($is_hot); $listarray=array(); if ($_SESSION['role_id']==0) { $listCategories=$this->mdanhmuc->getListCM(); foreach ($listCategories as $category) { if ($this->mtintuc->countChildById($category['category_id'])==0) $listarray[$category['category_id']]=$category['category_name']; } } else { $userID=$_SESSION['user_id']; $categoriesId=$this->mtintuc->getCategoryIDByUserId($userID); foreach ($categoriesId as $categoryId) { $category=$this->mtintuc->getCategoryById($categoryId); if ($this->mtintuc->countChildById($category['category_id'])==0) $listarray[$category['category_id']]=$category['category_name']; } } $el=$form->createElement("select","category_id",array( "multioptions"=> $listarray)); $el->removeDecorator('HtmlTag')->removeDecorator('Label'); $form->addElement($el); return $form; }
public function init() { $myNamespace = new Zend_Session_Namespace(Constant::USER_DATA); $searchData = $myNamespace->searchData; $this->setMethod('POST'); $this->setName('searchForm'); $element = new Zend_Form_Element_Radio('type'); $element->addMultiOptions(array('all' => '全部', 'lease' => '供', 'want' => '求')); if (!empty($searchData[Constant::VAR_SEARCH_DATA_TYPE])) { $element->setValue($searchData[Constant::VAR_SEARCH_DATA_TYPE]); } else { $element->setValue('all'); } $element->setSeparator(''); $element->removeDecorator('Label'); $this->addElement($element); // $element = new Zend_Form_Element_Checkbox("search_business"); // $element->setValue(0); // $this->addElement($element); $element = new Zend_Form_Element_Hidden('status'); $element->setValue('active'); $this->addElement($element); /*$element = new Zend_Form_Element_Text('rent'); $element->setLabel('租金'); $this->addElement($element); $element = new Zend_Form_Element_Radio('rent_measurement'); $element->setMultiOptions( array( 'day' => '克朗每日', 'month' => '克朗每月' ) ); $element->setSeparator(''); $element->removeDecorator('Label'); $element->setValue('month'); $this->addElement($element);*/ $element = new Zend_Form_Element_Text(Constant::VAR_SEARCH_DATA_CHECKIN_DATE); $element->setLabel('入住日期'); //$element->setDescription('例:2010-10-20'); if (!empty($searchData[Constant::VAR_SEARCH_DATA_CHECKIN_DATE])) { $element->setValue($searchData[Constant::VAR_SEARCH_DATA_CHECKIN_DATE]); } $this->addElement($element); $element = new Zend_Form_Element_Text(Constant::VAR_SEARCH_DATA_CHECKOUT_DATE); $element->setLabel('搬出日期(留空为长期)'); if (!empty($searchData[Constant::VAR_SEARCH_DATA_CHECKOUT_DATE]) && $searchData[Constant::VAR_SEARCH_DATA_CHECKOUT_DATE] != Constant::DEFAULT_CHECKOUT_DATE) { $element->setValue($searchData[Constant::VAR_SEARCH_DATA_CHECKOUT_DATE]); } $this->addElement($element); $element = new Zend_Form_Element_Text("keyword"); $element->setLabel("关键字"); //$element->setDescription("例:女生,lappis"); if (!empty($searchData[Constant::VAR_SEARCH_DATA_KEYWORD])) { $element->setValue($searchData[Constant::VAR_SEARCH_DATA_KEYWORD]); } $this->addElement($element); // $element = new Zend_Form_Element_Radio('sortedBy'); // $element->setLabel('排序'); // $element->addMultiOptions(array( // 'created' => '发帖时间', // 'rent' => '房租' // )); // $element->setSeparator(''); // $element->setValue('created'); // $this->addElement($element); // // $element = new Zend_Form_Element_Hidden('city'); // $element->setValue($this->city); // $element->removeDecorator('Label'); // $this->addElement($element); $element = new Zend_Form_Element_Submit('search'); $element->setValue('搜索'); $element->removeDecorator('Label'); $this->addElement($element); }
/** * Add a radio button element to the form. * * @param array $question * * @return void */ private function _addSingleChoice($question) { $elemName = $question['FQT_TypeName'] . self::UNDERSCORE . $question['FQ_ElementID']; $element = new Zend_Form_Element_Radio($elemName); $element->removeDecorator('DtDdWrapper'); $element->addDecorators(array('ViewHelper', array('HtmlTag', array('tag' => 'div', 'class' => 'answer-zone')))); $this->_addExtras($element, $question); $this->addElement($element); $this->_displayGroupElements[] = $elemName; }
/** * Get Radio Option * @param string $id * @param array $option * @param string $value * @return Zend_Form_Element_Radio */ public function getRadios($id, $option, $value = '', $elementequired = false) { $element = new Zend_Form_Element_Radio($id); $element->addMultiOptions($option); $element->removeDecorator('HtmlTag'); $element->removeDecorator('DtDdWrapper'); $element->removeDecorator('Label'); $element->setSeparator('<br/>'); if ($value !== '') { $element->setValue($value); } if ($elementequired) { $element->setAttribs(array('class' => 'validate[required] radio')); } return $element; }