/** * * Edit Album form * */ public function init() { $cname = explode('_', get_class()); $this->preInit(end($cname)); // use template file $this->setDecorators(array(array('ViewScript', array('viewScript' => 'forms/EditAlbum.phtml')))); // get group from database $request = Zend_Controller_Front::getInstance()->getRequest(); $album_id = $request->getParam('id'); $Albums = new Application_Model_Albums(); $album = $Albums->getAlbum($album_id); $username_minchars = Zend_Registry::get('config')->get('username_minchars'); $username_maxchars = Zend_Registry::get('config')->get('username_maxchars'); // fields $id = new Zend_Form_Element_Hidden('id'); $id->setValue($album); $album_name = new Zend_Form_Element_Text('album_name'); $album_name->setDecorators(array('ViewHelper', 'Errors'))->addFilter('StringTrim')->addValidator('alnum', false, array('allowWhiteSpace' => true))->addValidator('stringLength', false, array($username_minchars, $username_maxchars))->setErrorMessages(array(sprintf($this->translator->translate('Please choose a valid name between %d and %d characters'), $username_minchars, $username_maxchars)))->setLabel($this->translator->translate('Album Name'))->setRequired(true)->setValue($album['name'])->setAttrib('class', 'form-control'); $description = new Zend_Form_Element_Textarea('description'); $description->setDecorators(array('ViewHelper', 'Errors'))->setAttrib('COLS', '')->setAttrib('ROWS', '4')->addFilter('StripTags')->setValue($album['description'])->setLabel($this->translator->translate('About this album'))->setAttrib('class', 'form-control'); $submit = new Zend_Form_Element_Submit('formsubmit'); $submit->setDecorators(array('ViewHelper'))->setLabel($this->translator->translate('Save'))->setAttrib('class', 'submit btn btn-default'); $this->addElements(array($id, $album_name, $description, $submit)); $this->postInit(); }
protected function _mensagem() { $e = new Zend_Form_Element_Textarea('mensagem'); $e->setLabel('Mensagem:')->setRequired(true)->setAttrib('rows', 5)->addFilter('StringTrim')->setAttrib('class', 'form-control'); $e->setDecorators(array('ViewHelper', 'Description', 'Errors', array('HtmlTag', ''), array('Label', ''))); return $e; }
public function init() { // contato_nome $contato_nome = new Zend_Form_Element_Text("contato_nome"); $contato_nome->setLabel("Nome"); $contato_nome->setRequired(); $contato_nome->setAttribs(array('class' => 'form-control')); $contato_nome->setDecorators(App_Forms_Decorators::$simpleElementDecorators); // contato_email $contato_email = new Zend_Form_Element_Text("contato_email"); $contato_email->setLabel("E-mail"); $contato_email->setRequired(); $contato_email->setAttribs(array('class' => 'form-control')); $contato_email->setDecorators(App_Forms_Decorators::$simpleElementDecorators); // contato_assunto $contato_assunto = new Zend_Form_Element_Select("contato_assunto"); $contato_assunto->setLabel("Assunto"); $contato_assunto->setRequired(); $contato_assunto->setAttribs(array('class' => 'form-control')); $contato_assunto->setDecorators(App_Forms_Decorators::$simpleElementDecorators); $contato_assunto->setMultiOptions(array("" => "Selecione o assunto...", "Informação" => "Informação", "Elogio" => "Eologio", "Crítica" => "Crítica", "Sugestão" => "Sugestão", "Outros" => "Outros")); // contato_mensagem $contato_mensagem = new Zend_Form_Element_Textarea("contato_mensagem"); $contato_mensagem->setLabel("mensagem"); $contato_mensagem->setRequired(); $contato_mensagem->setAttribs(array('class' => 'form-control', 'rows' => 5)); $contato_mensagem->setDecorators(App_Forms_Decorators::$simpleElementDecorators); $this->addElements(array($contato_nome, $contato_email, $contato_assunto, $contato_mensagem)); parent::init(); }
public function init() { // attribs $this->setAttribs(array('id' => 'form-site-contato')); $this->setMethod('post'); $this->setAction('contato/'); // contato_nome $contato_nome = new Zend_Form_Element_Text('contato_nome'); $contato_nome->setLabel("Nome:"); $contato_nome->setRequired(); $contato_nome->addErrorMessages(array(Zend_Validate_NotEmpty::IS_EMPTY => "Campo obrigatório!")); $contato_nome->setAttrib('class', 'form-control'); $contato_nome->setAttrib('placeholder', 'Informe seu nome'); $contato_nome->setDecorators(App_Forms_Decorators::$simpleElementDecorators); // contato_email $contato_email = new Zend_Form_Element_Text('contato_email'); $contato_email->setLabel("E-mail:"); $contato_email->setRequired(); $contato_email->addErrorMessages(array(Zend_Validate_EmailAddress::INVALID => "Email inválido!")); $contato_email->addValidator('EmailAddress'); $contato_email->setAttrib('class', 'form-control'); $contato_email->setAttrib('placeholder', 'Informe seu email'); $contato_email->setDecorators(App_Forms_Decorators::$simpleElementDecorators); // contato_mensagem $contato_mensagem = new Zend_Form_Element_Textarea('contato_mensagem'); $contato_mensagem->setLabel("Mensagem:"); $contato_mensagem->setRequired(); $contato_mensagem->addErrorMessages(array(Zend_Validate_NotEmpty::IS_EMPTY => "Campo obrigatório!")); $contato_mensagem->setAttrib('class', 'form-control'); $contato_mensagem->setAttrib('placeholder', 'Digite aqui sua mensagem'); $contato_mensagem->setAttrib('rows', 5); $contato_mensagem->setDecorators(App_Forms_Decorators::$simpleElementDecorators); $this->addElements(array($contato_nome, $contato_email, $contato_mensagem)); parent::init(); }
/** * * Themes & styles * */ public function init() { $cname = explode('_', get_class()); $this->preInit(end($cname)); // use template file $this->setDecorators(array(array('ViewScript', array('viewScript' => 'forms/SettingsStyles.phtml')))); // load settings $AppOptions = new Application_Model_AppOptions(); $all_meta = $AppOptions->getAllOptions(); // fields $themes_array = array('/bootstrap/css/bootstrap.min.css' => 'Bootstrap'); $css_theme = new Zend_Form_Element_Select('css_theme'); $css_theme->setDecorators(array('ViewHelper', 'Errors'))->setMultiOptions($themes_array)->setErrorMessages(array($this->translator->translate('Please select')))->setLabel($this->translator->translate('Choose css theme'))->setRequired(true)->setValue(isset($all_meta['css_theme']) ? $all_meta['css_theme'] : 'bootstrap')->setAttrib('class', 'form-control'); $wide_layout = new Zend_Form_Element_Checkbox('wide_layout'); $wide_layout->setDecorators(array('ViewHelper', 'Errors'))->setValue(isset($all_meta['wide_layout']) && $all_meta['wide_layout'] == 1 ? 1 : 0)->setLabel($this->translator->translate('Extra-wide layout on large screens'))->setCheckedValue("1")->setUncheckedValue("0"); $cover_ysize = new Zend_Form_Element_Text('cover_ysize'); $cover_ysize->setDecorators(array('ViewHelper', 'Errors'))->setLabel($this->translator->translate('Cover image height'))->setValidators(array('digits'))->setRequired(true)->setValue(isset($all_meta['cover_ysize']) ? $all_meta['cover_ysize'] : '220')->setAttrib('class', 'form-control'); $user_background = new Zend_Form_Element_Checkbox('user_background'); $user_background->setDecorators(array('ViewHelper', 'Errors'))->setValue(isset($all_meta['user_background']) && $all_meta['user_background'] == 1 ? 1 : 0)->setLabel($this->translator->translate('Users can have custom background image'))->setCheckedValue("1")->setUncheckedValue("0"); $subscriber_background = new Zend_Form_Element_Checkbox('subscriber_background'); $subscriber_background->setDecorators(array('ViewHelper', 'Errors'))->setValue(isset($all_meta['subscriber_background']) && $all_meta['subscriber_background'] == 1 ? 1 : 0)->setLabel($this->translator->translate('Subscribers can have custom background image'))->setCheckedValue("1")->setUncheckedValue("0"); $custom_css = new Zend_Form_Element_Textarea('css_custom'); $custom_css->setDecorators(array('ViewHelper', 'Errors'))->setAttrib('COLS', '')->setAttrib('ROWS', '15')->setValue(isset($all_meta['css_custom']) ? $all_meta['css_custom'] : '')->setLabel($this->translator->translate('Custom css'))->setAttrib('class', 'form-control'); $submit = new Zend_Form_Element_Submit('submitbtn'); $submit->setDecorators(array('ViewHelper'))->setLabel($this->translator->translate('Update'))->setAttrib('class', 'submit btn btn-default'); $this->addElements(array($css_theme, $wide_layout, $cover_ysize, $user_background, $subscriber_background, $custom_css, $submit)); $this->postInit(); }
/** * * Edit Group form * */ public function init() { $cname = explode('_', get_class()); $this->preInit(end($cname)); // use template file $this->setDecorators(array(array('ViewScript', array('viewScript' => 'forms/EditGroup.phtml')))); // get group from database $request = Zend_Controller_Front::getInstance()->getRequest(); $group = $request->getParam('name'); $Profiles = new Application_Model_Profiles(); $ProfilesMeta = new Application_Model_ProfilesMeta(); $profile = $Profiles->getProfile($group, false, true); $owners_profile = $Profiles->getProfileByField('id', $profile->owner); $username_minchars = Zend_Registry::get('config')->get('username_minchars'); $username_maxchars = Zend_Registry::get('config')->get('username_maxchars'); // fields $id = new Zend_Form_Element_Hidden('id'); $id->setValue($profile->id); $name = new Zend_Form_Element_Text('name'); $name->setDecorators(array('ViewHelper', 'Errors'))->setLabel($this->translator->translate('Group Name'))->setValue($profile->name)->setIgnore(true)->setAttrib('readonly', true)->setAttrib('class', 'form-control'); $screenname = new Zend_Form_Element_Text('screen_name'); $screenname->setDecorators(array('ViewHelper', 'Errors'))->addFilter('StringTrim')->setValue($profile->screen_name)->addValidator('alnum', false, array('allowWhiteSpace' => true))->addValidator('stringLength', false, array($username_minchars, $username_maxchars))->setErrorMessages(array(sprintf($this->translator->translate('Please choose a valid name between %d and %d characters'), $username_minchars, $username_maxchars)))->setLabel($this->translator->translate('Screen Name'))->setRequired(true)->setAttrib('class', 'form-control'); $description = new Zend_Form_Element_Textarea('description'); $description->setDecorators(array('ViewHelper', 'Errors'))->setAttrib('COLS', '')->setAttrib('ROWS', '4')->addFilter('StripTags')->setValue($ProfilesMeta->getMetaValue('description', $profile->id))->setLabel($this->translator->translate('About this group'))->setAttrib('class', 'form-control'); $profile_privacy = new Zend_Form_Element_Select('profile_privacy'); $profile_privacy->setDecorators(array('ViewHelper', 'Errors'))->setMultiOptions(Zend_Registry::get('group_privacy_array'))->setErrorMessages(array($this->translator->translate('Select group visibility')))->setLabel($this->translator->translate('Select group visibility'))->setRequired(true)->setValue($profile->profile_privacy)->setAttrib('class', 'form-control'); $is_hidden = new Zend_Form_Element_Checkbox('is_hidden'); $is_hidden->setDecorators(array('ViewHelper', 'Errors'))->setValue(isset($profile->is_hidden) && $profile->is_hidden == 1 ? 1 : 0)->setLabel($this->translator->translate('Remove?'))->setCheckedValue("1")->setUncheckedValue("0"); $submit = new Zend_Form_Element_Submit('formsubmit'); $submit->setDecorators(array('ViewHelper'))->setLabel($this->translator->translate('Save'))->setAttrib('class', 'submit btn btn-default'); $this->addElements(array($id, $name, $screenname, $profile_privacy, $description, $is_hidden, $submit)); $this->postInit(); }
protected function _resumo() { $e = new Zend_Form_Element_Textarea('resumo'); $e->setLabel(_('Abstract:'))->setRequired(true)->setAttrib('rows', 10)->setAttrib("data-required", "true")->addFilter('StringTrim')->setAttrib('class', 'form-control')->addValidator('stringLength', false, array(20))->addFilter(new Sige_Filter_HTMLPurifier())->addErrorMessage("Resumo com número insuficiente de caracteres (mín. 20)."); $e->setDecorators(array('ViewHelper', 'Description', 'Errors', array('HtmlTag', ''), array('Label', ''))); return $e; }
public function init() { // agenda_cancelado_motivo $agenda_cancelado_motivo = new Zend_Form_Element_Textarea("agenda_cancelado_motivo"); $agenda_cancelado_motivo->setLabel("Motivo cancelamento: "); $agenda_cancelado_motivo->setRequired(); $agenda_cancelado_motivo->setDecorators(App_Forms_Decorators::$simpleElementDecorators); $agenda_cancelado_motivo->setAttribs(array('class' => 'form-control', 'placeholder' => 'Informe o motivo do cancelamento', 'rows' => 10)); $this->addElements(array($agenda_cancelado_motivo)); parent::init(); }
/** * @author code generate * @return mixed */ public function __construct($option = array()) { $contactId = new Zend_Form_Element_Hidden('ContactId'); $contactId->setDecorators(array('ViewHelper')); $this->addElement($contactId); $contactName = new Zend_Form_Element_Text('ContactName'); $contactName->setLabel('Họ tên *'); $contactName->addFilter('StringTrim'); $contactName->setRequired(true); $contactName->setDecorators(array('ViewHelper', array(array('control' => 'HtmlTag'), array('tag' => 'div', 'class' => 'element-control')), array('Label', array('class' => 'col-lg-2 control-label')), array(array('controls' => 'HtmlTag'), array('tag' => 'div', 'class' => 'form-group')))); $contactName->addValidator('stringLength', false, array(1, 50, "messages" => " dài tối đa 50 ký tự")); $this->addElement($contactName); $userId = new Zend_Form_Element_Text('UserId'); $userId->setLabel('UserId'); $userId->addFilter('StringTrim'); $userId->setAttrib('disabled', true); $userId->setDecorators(array('ViewHelper')); $this->addElement($userId); $contactPhone = new Zend_Form_Element_Text('ContactPhone'); $contactPhone->setLabel('Điện thoại *'); $contactPhone->addFilter('StringTrim'); $contactPhone->setRequired(true); $contactPhone->setDecorators(array('ViewHelper', array(array('control' => 'HtmlTag'), array('tag' => 'div', 'class' => 'element-control')), array('Label', array('class' => 'col-lg-2 control-label')), array(array('controls' => 'HtmlTag'), array('tag' => 'div', 'class' => 'form-group')))); $contactPhone->addValidator('stringLength', false, array(1, 15, "messages" => " dài tối đa 50 ký tự")); $this->addElement($contactPhone); $contactTitle = new Zend_Form_Element_Text('ContactTitle'); $contactTitle->setLabel('Tiêu đề *'); $contactTitle->addFilter('StringTrim'); $contactTitle->setRequired(true); $contactTitle->setDecorators(array('ViewHelper', array(array('control' => 'HtmlTag'), array('tag' => 'div', 'class' => 'element-control')), array('Label', array('class' => 'col-lg-2 control-label')), array(array('controls' => 'HtmlTag'), array('tag' => 'div', 'class' => 'form-group')))); $contactTitle->addValidator('stringLength', false, array(1, 250, "messages" => " dài tối đa 250 ký tự")); $this->addElement($contactTitle); $contactContent = new Zend_Form_Element_Textarea('ContactContent'); $contactContent->setLabel('Nội dung *'); $contactContent->setRequired(true); $contactContent->setOptions(array('cols' => '10', 'rows' => '4')); $contactContent->setDecorators(array('ViewHelper', array(array('control' => 'HtmlTag'), array('tag' => 'div', 'class' => 'element-control')), array('Label', array('class' => 'col-lg-2 control-label')), array(array('controls' => 'HtmlTag'), array('tag' => 'div', 'class' => 'form-group')))); $contactPhone->addValidator('stringLength', false, array(1, 2000, "messages" => " dài tối đa 2000 ký tự")); $this->addElement($contactContent); $save = new Zend_Form_Element_Submit('Save'); $save->setLabel('Gửi'); $save->setAttrib('class', 'btn btn-primary'); $save->setDecorators(array('ViewHelper')); $this->addElement($save); $reset = new Zend_Form_Element_Reset('Reset'); $reset->setLabel('Làm lại'); $reset->setAttrib('class', 'btn btn-primary'); $reset->setDecorators(array('ViewHelper')); $this->addElement($reset); }
/** * * Edit comment * */ public function init() { $cname = explode('_', get_class()); $this->preInit(end($cname)); // use template file $this->setDecorators(array(array('ViewScript', array('viewScript' => 'forms/EditComment.phtml')))); // fields $comment = new Zend_Form_Element_Textarea('comment'); $comment->setDecorators(array('ViewHelper', 'Errors'))->setAttrib('COLS', '')->setAttrib('ROWS', '4')->addFilter('StripTags')->setAttrib('class', 'form-control'); $submit = new Zend_Form_Element_Submit('submitcomment'); $submit->setDecorators(array('ViewHelper'))->setLabel($this->translator->translate('Save'))->setAttrib('class', 'submit btn btn-default'); $this->addElements(array($comment, $submit)); $this->postInit(); }
/** * * Edit post * */ public function init() { $cname = explode('_', get_class()); $this->preInit(end($cname)); // use template file $this->setDecorators(array(array('ViewScript', array('viewScript' => 'forms/EditPost.phtml')))); // fields $text = new Zend_Form_Element_Textarea('content'); $text->setDecorators(array('ViewHelper', 'Errors'))->setAttrib('COLS', '')->setAttrib('ROWS', '8')->addFilter('StripTags')->setAttrib('class', 'form-control'); $privacy = new Zend_Form_Element_Select('privacy'); $privacy->setDecorators(array('ViewHelper', 'Errors'))->setMultiOptions(Zend_Registry::get('post_privacy_array'))->setErrorMessages(array($this->translator->translate('Select post privacy')))->setLabel($this->translator->translate('Privacy'))->setAttrib('class', 'form-control'); $submit = new Zend_Form_Element_Submit('submitbutton'); $submit->setDecorators(array('ViewHelper'))->setLabel($this->translator->translate('Save'))->setAttrib('class', 'submit btn btn-default'); $this->addElements(array($text, $privacy, $submit)); $this->postInit(); }
/** * * @param array $options Options to build the form */ public function __construct($options = null) { // Disable the defaults buttons if (isset($options['disableAction'])) { $this->_disabledDefaultActions = $options['disableAction']; } if (isset($options['recipients'])) { $recipients = $options['recipients']; $recipientsList = $this->_setRecipientList($recipients); unset($options['recipients']); } parent::__construct($options); // Title $title = new Zend_Form_Element_Text('FI_Title'); $title->setLabel($this->getView()->getCibleText('form_label_title'))->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->setDecorators(array('ViewHelper', array('label', array('placement' => 'prepend')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'form_title_inline', 'id' => 'title'))))->setAttrib('class', 'stdTextInput'); $this->addElement($title); // Notification $notification = new Zend_Form_Element_Checkbox('F_Notification'); $notification->setLabel($this->getView()->getCibleText('form_label_has_notification')); $notification->setDecorators(array('ViewHelper', array('label', array('placement' => 'append')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'label_after_checkbox')))); $this->addElement($notification); $emailList = new Zend_Form_Element_Textarea('FN_Email'); $emailList->setAttrib('title', $this->getView()->getCibleText('form_notification_emails_info')); if (!empty($recipientsList)) { $emailList->setValue($recipientsList); } $emailList->setDecorators(array('ViewHelper', array('label', array('placement' => 'prepend')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'formRecipientsEmail')))); $this->addElement($emailList); // isSercure // $hasProfil = new Zend_Form_Element_Checkbox('F_Profil'); // $hasProfil->setLabel($this->getView()->getCibleText( // 'form_label_has_profil')); // $hasProfil->setDecorators(array( // 'ViewHelper', // array('label', array('placement' => 'append')), // array( // array('row' => 'HtmlTag'), // array('tag' => 'dd', 'class' => 'label_after_checkbox')), // )); // // $this->addElement($hasProfil); //hasCaptcha $hasCaptcha = new Zend_Form_Element_Checkbox('F_Captcha'); $hasCaptcha->setLabel($this->getView()->getCibleText('form_label_has_captcha'))->setValue(true)->setDecorators(array('ViewHelper', array('label', array('placement' => 'append')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'label_after_checkbox')))); $this->addElement($hasCaptcha); $this->setAttrib('id', 'Form'); }
/** * * Edit Profile form * */ public function init() { $cname = explode('_', get_class()); $this->preInit(end($cname)); // use template file $this->setDecorators(array(array('ViewScript', array('viewScript' => 'forms/Profile.phtml')))); // get user from database $Profiles = new Application_Model_Profiles(); $ProfilesMeta = new Application_Model_ProfilesMeta(); $profile = $Profiles->getProfile(Zend_Auth::getInstance()->getIdentity()->name, true); $all_meta = $ProfilesMeta->getMetaValues($profile->id); $username_minchars = Zend_Registry::get('config')->get('username_minchars'); $username_maxchars = Zend_Registry::get('config')->get('username_maxchars'); // fields $id = new Zend_Form_Element_Hidden('id'); $id->setValue($profile->id); $name = new Zend_Form_Element_Text('name'); $name->setDecorators(array('ViewHelper', 'Errors'))->setLabel($this->translator->translate('Username'))->setValue($profile->name)->setIgnore(true)->setAttrib('readonly', true)->setAttrib('class', 'form-control'); $email = new Zend_Form_Element_Text('email'); $email->setDecorators(array('ViewHelper', 'Errors'))->setLabel($this->translator->translate('Email'))->setValue($profile->email)->setIgnore(true)->setAttrib('readonly', true)->setAttrib('class', 'form-control'); $screenname = new Zend_Form_Element_Text('screen_name'); $screenname->setDecorators(array('ViewHelper', 'Errors'))->addFilter('StringTrim')->setValue($profile->screen_name)->addValidator('alnum', false, array('allowWhiteSpace' => true))->addValidator('stringLength', false, array($username_minchars, $username_maxchars))->setErrorMessages(array(sprintf($this->translator->translate('Please choose a valid name between %d and %d characters'), $username_minchars, $username_maxchars)))->setLabel($this->translator->translate('Screen Name'))->setRequired(true)->setAttrib('class', 'form-control'); $description = new Zend_Form_Element_Textarea('description'); $description->setDecorators(array('ViewHelper', 'Errors'))->setAttrib('COLS', '')->setAttrib('ROWS', '4')->addFilter('StripTags')->setValue(isset($all_meta['description']) ? $all_meta['description'] : '')->setLabel($this->translator->translate('About you'))->setAttrib('class', 'form-control'); $profile_privacy = new Zend_Form_Element_Select('profile_privacy'); $profile_privacy->setDecorators(array('ViewHelper', 'Errors'))->setMultiOptions(Zend_Registry::get('profile_privacy_array'))->setErrorMessages(array($this->translator->translate('Select profile visibility')))->setLabel($this->translator->translate('Profile visibility'))->setRequired(true)->setValue($profile->profile_privacy)->setAttrib('class', 'form-control'); $birthday = new Application_Form_Element_Date('birthday'); $birthday->setDecorators(array('ViewHelper', 'Errors'))->setAttrib('class', 'form-control')->setLabel($this->translator->translate('Date of birth'))->setErrorMessages(array($this->translator->translate('Please enter a valid date')))->setYearSpan(1920, date('Y') - 1); if (isset($all_meta['birthday'])) { $timestamp = strtotime($all_meta['birthday']); $birthday->setValue(array('day' => date('d', $timestamp), 'month' => date('m', $timestamp), 'year' => date('Y', $timestamp))); } $gender = new Zend_Form_Element_Select('gender'); $gender->setDecorators(array('ViewHelper', 'Errors'))->setMultiOptions(Zend_Registry::get('genders_array'))->setErrorMessages(array($this->translator->translate('Please select something')))->setLabel($this->translator->translate('Gender'))->setRequired(true)->setValue(isset($all_meta['gender']) ? $all_meta['gender'] : '')->setAttrib('class', 'form-control'); $online_status = new Zend_Form_Element_Select('show_online_status'); $online_status->setDecorators(array('ViewHelper', 'Errors'))->setMultiOptions(Zend_Registry::get('onlinestatus_array'))->setErrorMessages(array($this->translator->translate('Select profile visibility')))->setLabel($this->translator->translate('Online Status'))->setRequired(true)->setValue(isset($all_meta['show_online_status']) ? $all_meta['show_online_status'] : 's')->setAttrib('class', 'form-control'); $contact_privacy = new Zend_Form_Element_Select('contact_privacy'); $contact_privacy->setDecorators(array('ViewHelper', 'Errors'))->setMultiOptions(Zend_Registry::get('contactprivacy_array'))->setErrorMessages(array($this->translator->translate('Please select something')))->setLabel($this->translator->translate('Who can contact me?'))->setRequired(true)->setValue(isset($all_meta['contact_privacy']) ? $all_meta['contact_privacy'] : 'e')->setAttrib('class', 'form-control'); $location = new Zend_Form_Element_Text('location'); $location->setDecorators(array('ViewHelper', 'Errors'))->setRequired(false)->setLabel($this->translator->translate('Location'))->setAttrib('class', 'form-control')->addFilter('StripTags')->setValue(isset($all_meta['location']) ? $all_meta['location'] : '')->setErrorMessages(array($this->translator->translate('Enter a valid location'))); $website = new Zend_Form_Element_Text('website'); $website->setDecorators(array('ViewHelper', 'Errors'))->setRequired(false)->setLabel($this->translator->translate('Website'))->setAttrib('class', 'form-control')->addFilter('StripTags')->setValue(isset($all_meta['website']) ? $all_meta['website'] : '')->setErrorMessages(array($this->translator->translate('Enter a valid website'))); $submit = new Zend_Form_Element_Submit('formsubmit'); $submit->setDecorators(array('ViewHelper'))->setLabel($this->translator->translate('Save'))->setAttrib('class', 'submit btn btn-default form-control'); $this->addElements(array($id, $name, $email, $screenname, $gender, $profile_privacy, $online_status, $contact_privacy, $description, $location, $website, $birthday, $submit)); $this->postInit(); }
/** * * Add new post * */ public function init() { $cname = explode('_', get_class()); $this->preInit(end($cname), true, false); // show privacy $show_privacy = new Zend_Form_Element_Hidden('show_privacy'); $show_privacy->setDecorators(array('ViewHelper'))->setValue($this->show_privacy); // use template file $this->setDecorators(array(array('ViewScript', array('viewScript' => 'forms/AddPost.phtml')))); // fields $text = new Zend_Form_Element_Textarea('content'); $text->setDecorators(array('ViewHelper', 'Errors'))->setAttrib('COLS', '')->setAttrib('ROWS', '4')->addFilter('StripTags')->setAttrib('class', 'form-control')->setAttrib('placeholder', $this->translator->translate('What is on your mind?')); $submit = new Zend_Form_Element_Submit('submitbutton'); $submit->setDecorators(array('ViewHelper'))->setLabel($this->translator->translate('Post'))->setAttrib('class', 'submit btn btn-default'); $this->addElements(array($text, $submit)); $this->postInit(); }
/** * * Add Album * */ public function init() { $cname = explode('_', get_class()); $this->preInit(end($cname)); // use template file $this->setDecorators(array(array('ViewScript', array('viewScript' => 'forms/AddAlbum.phtml')))); $username_minchars = Zend_Registry::get('config')->get('username_minchars'); $username_maxchars = Zend_Registry::get('config')->get('username_maxchars'); // fields $album_name = new Zend_Form_Element_Text('album_name'); $album_name->setDecorators(array('ViewHelper', 'Errors'))->addFilter('StringTrim')->addValidator('alnum', false, array('allowWhiteSpace' => true))->addValidator('stringLength', false, array($username_minchars, $username_maxchars))->setErrorMessages(array(sprintf($this->translator->translate('Please choose a valid name between %d and %d characters'), $username_minchars, $username_maxchars)))->setLabel($this->translator->translate('Album Name'))->setRequired(true)->setAttrib('class', 'form-control'); $description = new Zend_Form_Element_Textarea('description'); $description->setDecorators(array('ViewHelper', 'Errors'))->setAttrib('COLS', '')->setAttrib('ROWS', '4')->addFilter('StripTags')->setLabel($this->translator->translate('About this album'))->setAttrib('class', 'form-control'); $submit = new Zend_Form_Element_Submit('formsubmit'); $submit->setDecorators(array('ViewHelper'))->setLabel($this->translator->translate('Save'))->setAttrib('class', 'submit btn btn-default'); $this->addElements(array($album_name, $description, $submit)); $this->postInit(); }
/** * * General settings * */ public function init() { $cname = explode('_', get_class()); $this->preInit(end($cname)); // use template file $this->setDecorators(array(array('ViewScript', array('viewScript' => 'forms/Settings.phtml')))); // load settings $AppOptions = new Application_Model_AppOptions(); $all_meta = $AppOptions->getAllOptions(); // fields $global_head = new Zend_Form_Element_Textarea('global_head'); $global_head->setDecorators(array('ViewHelper', 'Errors'))->setAttrib('COLS', '')->setAttrib('ROWS', '8')->setValue(isset($all_meta['global_head']) ? $all_meta['global_head'] : '')->setLabel($this->translator->translate('Additional html for head section - show on global pages'))->setAttrib('class', 'form-control'); $profiles_head = new Zend_Form_Element_Textarea('profiles_head'); $profiles_head->setDecorators(array('ViewHelper', 'Errors'))->setAttrib('COLS', '')->setAttrib('ROWS', '8')->setValue(isset($all_meta['profiles_head']) ? $all_meta['profiles_head'] : '')->setLabel($this->translator->translate('Additional html for head section - show on profile pages (Tags: PROFILE_SCREEN_NAME, PROFILE_NAME, PROFILE_AVATAR, PROFILE_COVER, PROFILE_DESCRIPTION)'))->setAttrib('class', 'form-control'); $common_head = new Zend_Form_Element_Textarea('common_head'); $common_head->setDecorators(array('ViewHelper', 'Errors'))->setAttrib('COLS', '')->setAttrib('ROWS', '8')->setValue(isset($all_meta['common_head']) ? $all_meta['common_head'] : '')->setLabel($this->translator->translate('Additional html for head section - always show on all pages (common analytics code etc)'))->setAttrib('class', 'form-control'); $submit = new Zend_Form_Element_Submit('submitbtn'); $submit->setDecorators(array('ViewHelper'))->setLabel($this->translator->translate('Update'))->setAttrib('class', 'submit btn btn-default'); $this->addElements(array($global_head, $profiles_head, $common_head, $submit)); $this->postInit(); }
/** * * General settings * */ public function init() { $cname = explode('_', get_class()); $this->preInit(end($cname)); // use template file $this->setDecorators(array(array('ViewScript', array('viewScript' => 'forms/Settings.phtml')))); // load settings $AppOptions = new Application_Model_AppOptions(); $all_meta = $AppOptions->getAllOptions(); // fields $network_name = new Zend_Form_Element_Text('network_name'); $network_name->setDecorators(array('ViewHelper', 'Errors'))->setLabel($this->translator->translate('Network name'))->setValue(isset($all_meta['network_name']) ? $all_meta['network_name'] : 'MyNetwork')->setAttrib('class', 'form-control'); $description = new Zend_Form_Element_Textarea('network_description'); $description->setDecorators(array('ViewHelper', 'Errors'))->setAttrib('COLS', '')->setAttrib('ROWS', '4')->addFilter('StripTags')->setValue(isset($all_meta['network_description']) ? $all_meta['network_description'] : '')->setLabel($this->translator->translate('Description'))->setAttrib('class', 'form-control'); $license_code = new Zend_Form_Element_Text('license_code'); $license_code->setDecorators(array('ViewHelper', 'Errors'))->setLabel($this->translator->translate('Item Purchase Code'))->setValue(isset($all_meta['license_code']) ? $all_meta['license_code'] : '')->setAttrib('class', 'form-control'); $submit = new Zend_Form_Element_Submit('submitbtn'); $submit->setDecorators(array('ViewHelper'))->setLabel($this->translator->translate('Save'))->setAttrib('class', 'submit btn btn-default'); $this->addElements(array($network_name, $description, $license_code, $submit)); $this->postInit(); }
/** * * Add a Group * */ public function init() { $cname = explode('_', get_class()); $this->preInit(end($cname)); // use template file $this->setDecorators(array(array('ViewScript', array('viewScript' => 'forms/AddGroup.phtml')))); $username_minchars = Zend_Registry::get('config')->get('username_minchars'); $username_maxchars = Zend_Registry::get('config')->get('username_maxchars'); // fields // lowercase, alnum without whitespaces $name = new Zend_Form_Element_Text('name'); $name->setDecorators(array('ViewHelper', 'Errors'))->setRequired(true)->addFilter('StringToLower')->addValidator('alnum', false, array('allowWhiteSpace' => false))->addValidator('stringLength', false, array($username_minchars, $username_maxchars))->setErrorMessages(array(sprintf($this->translator->translate('Please choose a valid username between %d and %d characters'), $username_minchars, $username_maxchars)))->setLabel($this->translator->translate('Username'))->setAttrib('class', 'form-control alnum-only'); $screenname = new Zend_Form_Element_Text('screen_name'); $screenname->setDecorators(array('ViewHelper', 'Errors'))->addFilter('StringTrim')->addValidator('alnum', false, array('allowWhiteSpace' => true))->addValidator('stringLength', false, array($username_minchars, $username_maxchars))->setErrorMessages(array(sprintf($this->translator->translate('Please choose a valid name between %d and %d characters'), $username_minchars, $username_maxchars)))->setLabel($this->translator->translate('Screen Name'))->setRequired(true)->setAttrib('class', 'form-control'); $description = new Zend_Form_Element_Textarea('description'); $description->setDecorators(array('ViewHelper', 'Errors'))->setAttrib('COLS', '')->setAttrib('ROWS', '4')->addFilter('StripTags')->setLabel($this->translator->translate('About this group'))->setAttrib('class', 'form-control'); $profile_privacy = new Zend_Form_Element_Select('profile_privacy'); $profile_privacy->setDecorators(array('ViewHelper', 'Errors'))->setMultiOptions(Zend_Registry::get('group_privacy_array'))->setErrorMessages(array($this->translator->translate('Select group visibility')))->setLabel($this->translator->translate('Select group visibility'))->setRequired(true)->setAttrib('class', 'form-control'); $submit = new Zend_Form_Element_Submit('formsubmit'); $submit->setDecorators(array('ViewHelper'))->setLabel($this->translator->translate('Save'))->setAttrib('class', 'submit btn btn-default'); $this->addElements(array($screenname, $name, $profile_privacy, $description, $submit)); $this->postInit(); }
/** * * Edit Page form (admin only) * */ public function init() { $cname = explode('_', get_class()); $this->preInit(end($cname)); // use template file $this->setDecorators(array(array('ViewScript', array('viewScript' => 'forms/AdminPage.phtml')))); // get group from database $request = Zend_Controller_Front::getInstance()->getRequest(); $request_profile_id = $request->getParam('id'); $Profiles = new Application_Model_Profiles(); $ProfilesMeta = new Application_Model_ProfilesMeta(); $profile = $Profiles->getProfileByField('id', $request_profile_id); $owners_profile = $Profiles->getProfileByField('id', $profile->owner); // fields $profile_id = new Zend_Form_Element_Text('id'); $profile_id->setDecorators(array('ViewHelper', 'Errors'))->setLabel($this->translator->translate('Id'))->setValue($profile->id)->setIgnore(true)->setAttrib('readonly', true)->setAttrib('class', 'form-control'); $username_minchars = Zend_Registry::get('config')->get('username_minchars'); $username_maxchars = Zend_Registry::get('config')->get('username_maxchars'); // lowercase, alnum without whitespaces $name = new Zend_Form_Element_Text('name'); $name->setDecorators(array('ViewHelper', 'Errors'))->setRequired(true)->addFilter('StringToLower')->addValidator('alnum', false, array('allowWhiteSpace' => false))->addValidator('stringLength', false, array($username_minchars, $username_maxchars))->setErrorMessages(array(sprintf($this->translator->translate('Please choose a valid username between %d and %d characters'), $username_minchars, $username_maxchars)))->setAttrib('class', 'form-control alnum-only')->setValue($profile->name)->setLabel($this->translator->translate('Username')); $screenname = new Zend_Form_Element_Text('screen_name'); $screenname->setDecorators(array('ViewHelper', 'Errors'))->addFilter('StringTrim')->setValue($profile->screen_name)->addValidator('alnum', false, array('allowWhiteSpace' => true))->addValidator('stringLength', false, array($username_minchars, $username_maxchars))->setErrorMessages(array(sprintf($this->translator->translate('Please choose a valid name between %d and %d characters'), $username_minchars, $username_maxchars)))->setLabel($this->translator->translate('Screen Name'))->setRequired(true)->setAttrib('class', 'form-control'); $owner_name = isset($owners_profile->name) ? $owners_profile->name : '-'; $owner = new Zend_Form_Element_Text('owner'); $owner->setDecorators(array('ViewHelper', 'Errors'))->setLabel($this->translator->translate('Owner') . ' (' . $this->translator->translate('Current') . ': ' . $owner_name . ')')->setValue($owner_name)->setRequired(true)->setAttrib('class', 'form-control'); $badges = new Zend_Form_Element_Text('badges'); $badges->setDecorators(array('ViewHelper', 'Errors'))->setLabel($this->translator->translate('Badges based on Glyphicon font separated by comma (e.g. "bullhorn,earphone")'))->setValue($ProfilesMeta->getMetaValue('badges', $profile->id))->setAttrib('class', 'form-control'); $description = new Zend_Form_Element_Textarea('description'); $description->setDecorators(array('ViewHelper', 'Errors'))->setAttrib('COLS', '')->setAttrib('ROWS', '4')->addFilter('StripTags')->setValue($ProfilesMeta->getMetaValue('description', $profile->id))->setLabel($this->translator->translate('About this page'))->setAttrib('class', 'form-control'); $is_hidden = new Zend_Form_Element_Checkbox('is_hidden'); $is_hidden->setDecorators(array('ViewHelper', 'Errors'))->setValue(isset($profile->is_hidden) && $profile->is_hidden == 1 ? 1 : 0)->setLabel($this->translator->translate('Hide?'))->setCheckedValue("1")->setUncheckedValue("0"); $submit = new Zend_Form_Element_Submit('formsubmit'); $submit->setDecorators(array('ViewHelper'))->setLabel($this->translator->translate('Save'))->setAttrib('class', 'submit btn btn-default'); $this->addElements(array($profile_id, $owner, $name, $screenname, $badges, $description, $is_hidden, $submit)); $this->postInit(); }
/** * * General settings * */ public function init() { $cname = explode('_', get_class()); $this->preInit(end($cname)); // use template file $this->setDecorators(array(array('ViewScript', array('viewScript' => 'forms/Settings.phtml')))); // load settings $AppOptions = new Application_Model_AppOptions(); $all_meta = $AppOptions->getAllOptions(); // fields $motd = new Zend_Form_Element_Textarea('motd'); $motd->setDecorators(array('ViewHelper', 'Errors'))->setAttrib('COLS', '')->setAttrib('ROWS', '8')->setValue(isset($all_meta['motd']) ? $all_meta['motd'] : '')->setLabel($this->translator->translate('Message of the day'))->setAttrib('class', 'form-control'); $top_banner = new Zend_Form_Element_Textarea('top_banner'); $top_banner->setDecorators(array('ViewHelper', 'Errors'))->setAttrib('COLS', '')->setAttrib('ROWS', '8')->setValue(isset($all_meta['top_banner']) ? $all_meta['top_banner'] : '')->setLabel($this->translator->translate('Top Banner html'))->setAttrib('class', 'form-control'); $sidebar_banner = new Zend_Form_Element_Textarea('sidebar_banner'); $sidebar_banner->setDecorators(array('ViewHelper', 'Errors'))->setAttrib('COLS', '')->setAttrib('ROWS', '8')->setValue(isset($all_meta['sidebar_banner']) ? $all_meta['sidebar_banner'] : '')->setLabel($this->translator->translate('Sidebar Banner html'))->setAttrib('class', 'form-control'); // fields $middle_banner = new Zend_Form_Element_Textarea('middle_banner'); $middle_banner->setDecorators(array('ViewHelper', 'Errors'))->setAttrib('COLS', '')->setAttrib('ROWS', '8')->setValue(isset($all_meta['middle_banner']) ? $all_meta['middle_banner'] : '')->setLabel($this->translator->translate('Middle Banner html'))->setAttrib('class', 'form-control'); $submit = new Zend_Form_Element_Submit('submitbtn'); $submit->setDecorators(array('ViewHelper'))->setLabel($this->translator->translate('Update'))->setAttrib('class', 'submit btn btn-default'); $this->addElements(array($motd, $top_banner, $sidebar_banner, $middle_banner, $submit)); $this->postInit(); }
public function init() { // categoria_id $categoria_id = new Zend_Form_Element_Select("categoria_id"); $categoria_id->setLabel("Categoria: "); $categoria_id->setRequired(); $categoria_id->setDecorators(App_Forms_Decorators::$simpleElementDecorators); $categoria_id->setAttribs(array('class' => 'form-control')); $categoria_id->setMultiOptions($this->getCategorias()); // especialidade_nome $especialidade_nome = new Zend_Form_Element_Text("especialidade_nome"); $especialidade_nome->setLabel("Nome Especialidade: "); $especialidade_nome->setRequired(); $especialidade_nome->setDecorators(App_Forms_Decorators::$simpleElementDecorators); $especialidade_nome->setAttribs(array('class' => 'form-control')); // especialidade_descricao $especialidade_descricao = new Zend_Form_Element_Textarea("especialidade_descricao"); $especialidade_descricao->setLabel("Descrição Especialidade: "); $especialidade_descricao->setRequired(); $especialidade_descricao->setDecorators(App_Forms_Decorators::$simpleElementDecorators); $especialidade_descricao->setAttribs(array('class' => 'form-control', 'rows' => 5)); $this->addElements(array($categoria_id, $especialidade_nome, $especialidade_descricao)); parent::init(); }
protected function _tecnologias_envolvidas() { $e = new Zend_Form_Element_Textarea('tecnologias_envolvidas'); $e->setLabel(_('Technologies involved:'))->setAttrib('rows', 5)->setAttrib('placeholder', _('Need of an especific program or tool, distro, IDE, etc...'))->addFilter('StripTags')->addFilter('StringTrim'); $e->setAttrib('class', 'form-control'); $e->setDecorators(array('ViewHelper', 'Description', 'Errors', array('HtmlTag', ''), array('Label', ''))); return $e; }
public function init() { $this->setMethod("post"); $element = new Zend_Form_Element_Text("reference_no", array("label" => "Ref. No")); $element->addValidator(new Zend_Validate_UniqueRefNo(), true); $element->setRequired(true); $element->setDecorators(array(array('ViewScript', array('viewScript' => 'formElements/property/_textInput.phtml')))); $this->addElement($element); $element = new Zend_Form_Element_Text("price", array("label" => "Price")); $element->setDecorators(array(array('ViewScript', array('viewScript' => 'formElements/property/_textInput.phtml')))); $element->setRequired(true); $element->addValidator(new Zend_Validate_IsNumber(), true); $this->addElement($element); $element = new Zend_Form_Element_Text("title", array("label" => "Title")); $element->setDecorators(array(array('ViewScript', array('viewScript' => 'formElements/property/_textInput.phtml')))); $element->setRequired(true); $this->addElement($element); $locations = new Application_Model_PropertyLocationMapper(); foreach ($locations->fetchAll() as $value) { $options[$value->getId()] = $value->getCity() . " - " . $value->getCityPart(); } $buildingTypes = array(); $type = new Application_Model_PropertyBuildTypeMapper(); $buildingTypes[''] = 'Seleccione ...'; foreach ($type->fetchAll() as $value) { $buildingTypes[$value->getId()] = $value->getText(); } $element = new Zend_Form_Element_Select("property_build_id", array('label' => 'Building type')); $element->setMultiOptions($buildingTypes); $element->setDecorators(array(array('ViewScript', array('viewScript' => 'formElements/property/_select.phtml')))); $element->setRequired(true); $element->addValidator(new Zend_Validate_NotEmpty()); $this->addElement($element); $options = array(); for ($i = 0; $i < 25; $i++) { $options[$i] = $i; } $element = new Zend_Form_Element_Select("floor", array('label' => 'Floor')); $element->setMultiOptions($options); $element->setDecorators(array(array('ViewScript', array('viewScript' => 'formElements/property/_select.phtml')))); $element->setRequired(true); $element->addValidator(new Zend_Validate_NotEmpty()); $this->addElement($element); $options = array(); $dis = new Application_Model_DispositionMapper(); $options[''] = ''; foreach ($dis->fetchAll() as $value) { $options[$value->getId()] = $value->getText(); } $element = new Zend_Form_Element_Select("disposition_id", array('label' => 'Disposition')); $element->setMultiOptions($options); $element->setDecorators(array(array('ViewScript', array('viewScript' => 'formElements/property/_select.phtml')))); $element->setRequired(true); $element->addValidator(new Zend_Validate_NotEmpty()); $this->addElement($element); $element = new Zend_Form_Element_Text("area", array("label" => "Area (m²)")); $element->setDecorators(array(array('ViewScript', array('viewScript' => 'formElements/property/_textInput.phtml')))); $element->addValidator(new Zend_Validate_IsNumber(), true); $this->addElement($element); $element = new Zend_Form_Element_Text("cellar", array("label" => "Cellar (m²)")); $element->setDecorators(array(array('ViewScript', array('viewScript' => 'formElements/property/_textInput.phtml')))); $element->addValidator(new Zend_Validate_IsNumber(), true); $this->addElement($element); $element = new Zend_Form_Element_Text("balcony", array("label" => "Balcony (m²)")); $element->setDecorators(array(array('ViewScript', array('viewScript' => 'formElements/property/_textInput.phtml')))); $element->addValidator(new Zend_Validate_IsNumber(), true); $this->addElement($element); $element = new Zend_Form_Element_Text("terace", array("label" => "Terrace (m²)")); $element->setDecorators(array(array('ViewScript', array('viewScript' => 'formElements/property/_textInput.phtml')))); $element->addValidator(new Zend_Validate_IsNumber(), true); $this->addElement($element); $element = new Zend_Form_Element_Text("loggia", array("label" => "Loggia (m²)")); $element->setDecorators(array(array('ViewScript', array('viewScript' => 'formElements/property/_textInput.phtml')))); $element->addValidator(new Zend_Validate_IsNumber(), true); $this->addElement($element); $element = new Zend_Form_Element_Text("garage", array("label" => "Garage (m²)")); $element->setDecorators(array(array('ViewScript', array('viewScript' => 'formElements/property/_textInput.phtml')))); $element->addValidator(new Zend_Validate_IsNumber(), true); $this->addElement($element); $element = new Zend_Form_Element_Text("garden", array("label" => "Garden (m²)")); $element->setDecorators(array(array('ViewScript', array('viewScript' => 'formElements/property/_textInput.phtml')))); $element->addValidator(new Zend_Validate_IsNumber(), true); $this->addElement($element); $element = new Zend_Form_Element_Checkbox("lift", array("label" => "Lift")); $this->addElement($element); $element = new Zend_Form_Element_Checkbox("parking_place", array("label" => "Parking place:")); $this->addElement($element); $options = array(); $dis = new Application_Model_PropertyLocationMapper(); $options[''] = ''; foreach ($dis->fetchAll() as $value) { $options[$value->getId()] = $value->getCity() . " - " . $value->getCityPart(); } //die('$options::<pre>' . print_r($options,true) . '</pre>'); $element = new Zend_Form_Element_Select("location_id", array('label' => 'Location')); $element->setMultiOptions($options); $element->setDecorators(array(array('ViewScript', array('viewScript' => 'formElements/property/_select.phtml')))); $element->setRequired(true); $element->addValidator(new Zend_Validate_NotEmpty()); $this->addElement($element); $element = new Zend_Form_Element_Text("street", array("label" => "Address")); $element->setDecorators(array(array('ViewScript', array('viewScript' => 'formElements/property/_textInput.phtml')))); $this->addElement($element); $element = new Zend_Form_Element_Text("c1", array()); $element->setDecorators(array(array('ViewScript', array('viewScript' => 'formElements/property/_clear.phtml')))); $this->addElement($element); $element = new Zend_Form_Element_Textarea("text", array("label" => "Description")); $element->setDecorators(array(array('ViewScript', array('viewScript' => 'formElements/property/_textArea.phtml')))); $element->setRequired(true); $this->addElement($element); $element = new Zend_Form_Element_Submit("submit", array("value" => "Save", "class" => "button")); $element->setDecorators(array(array('ViewScript', array('viewScript' => 'formElements/property/_submit.phtml')))); $this->addElement($element); }
public function init() { $this->setMethod("post"); // produto_nome $produto_nome = new Zend_Form_Element_Text("produto_nome"); $produto_nome->setLabel("Nome"); $produto_nome->setRequired(); $produto_nome->setAttribs(array('class' => 'form-control', 'placeholder' => 'Informe o nome do produto')); $produto_nome->setDecorators(App_Forms_Decorators::$simpleElementDecorators); // produto_id $produto_id = new Zend_Form_Element_Hidden("produto_id"); // fabricante_nome $fabricante_nome = new Zend_Form_Element_Text("fabricante_nome"); $fabricante_nome->setLabel("Fabricante"); //$fabricante_nome->setRequired(); $fabricante_nome->setAttribs(array('class' => 'form-control', 'placeholder' => 'Informe o nome do fabricante')); $fabricante_nome->setDecorators(App_Forms_Decorators::$simpleElementDecorators); // fabricante_id $fabricante_id = new Zend_Form_Element_Hidden("fabricante_id"); // marca_nome $marca_nome = new Zend_Form_Element_Text("marca_nome"); $marca_nome->setLabel("Marca"); $marca_nome->setRequired(); $marca_nome->setAttribs(array('class' => 'form-control', 'placeholder' => 'Informe o nome da marca')); $marca_nome->setDecorators(App_Forms_Decorators::$simpleElementDecorators); // marca_id $marca_id = new Zend_Form_Element_Hidden("marca_id"); // reclamacao_nome $reclamacao_nome = new Zend_Form_Element_Text("reclamacao_nome"); $reclamacao_nome->setLabel("Nome"); $reclamacao_nome->setAttribs(array('class' => 'form-control', 'placeholder' => 'Informe seu nome')); // reclamacap_email $reclamacao_email = new Zend_Form_Element_Text("reclamacao_email"); $reclamacao_email->setLabel("E-mail"); $reclamacao_email->setAttribs(array('class' => 'form-control', 'placeholder' => 'Informe seu e-mail')); // reclamacao_empresa $reclamacao_empresa = new Zend_Form_Element_Text("reclamacao_empresa"); $reclamacao_empresa->setLabel("Empresa onde comprou o produto"); $reclamacao_empresa->setAttribs(array('class' => 'form-control', 'placeholder' => 'Informe seu e-mail')); // reclamacao_cidade $reclamacao_cidade = new Zend_Form_Element_Text("reclamacao_cidade"); $reclamacao_cidade->setLabel("Cidade"); $reclamacao_cidade->setAttribs(array('class' => 'form-control', 'placeholder' => 'Informe sua cidade')); // reclamacao_estado $reclamacao_estado = new Zend_Form_Element_Select("reclamacao_estado"); $reclamacao_estado->setLabel("Estado"); $reclamacao_estado->setAttribs(array('class' => 'form-control')); $reclamacao_estado->setMultiOptions($this->getEstados()); // reclamacao_descricao $reclamacao_descricao = new Zend_Form_Element_Textarea("reclamacao_descricao"); $reclamacao_descricao->setLabel("Descreva sua reclamação"); $reclamacao_descricao->setRequired(); $reclamacao_descricao->setDecorators(App_Forms_Decorators::$simpleElementDecorators); $reclamacao_descricao->setAttribs(array('class' => 'form-control', 'rows' => 5, 'placeholder' => 'Informe porque você está insatisfeito com o produto', 'maxlenght' => 500)); $reclamacao_descricao->addValidator(new App_Validate_Reclamacao()); // reclamacao_nota $reclamacao_nota = new Zend_Form_Element_Radio("reclamacao_nota"); $reclamacao_nota->setLabel("Dê sua nota para o produto"); $reclamacao_nota->setRequired(); $reclamacao_nota->setAttribs(array('class' => '')); $reclamacao_nota->setMultiOptions($this->getNotasHtml()); $reclamacao_nota->setOptions(array('escape' => false)); $reclamacao_nota->setSeparator(" "); $reclamacao_nota->setDecorators(App_Forms_Decorators::$checkboxElementDecorators); // submit $submit = new Zend_Form_Element_Submit("submit"); $submit->setLabel("Registrar Reclamação"); $submit->setAttrib("class", 'form-control btn btn-success'); $this->addElements(array($produto_nome, $fabricante_nome, $marca_nome, $reclamacao_descricao, $reclamacao_nome, $reclamacao_email, $reclamacao_cidade, $reclamacao_estado, $reclamacao_nota, $submit, $produto_id, $marca_id, $fabricante_id)); }
public function init() { $this->setMethod('post'); $this->setEnctype('multipart/form-data'); $this->setName('edit_profile_form'); $this->setAttrib('id', 'edit-profile-form'); $this->addElementPrefixPath('Oibs_Form_Decorator', 'Oibs/Form/Decorator/', 'decorator'); $mailvalid = new Zend_Validate_EmailAddress(); $mailvalid->setMessage('email-invalid', Zend_Validate_EmailAddress::INVALID); $mailvalid->setMessage('email-invalid-hostname', Zend_Validate_EmailAddress::INVALID_HOSTNAME); $mailvalid->setMessage('email-invalid-mx-record', Zend_Validate_EmailAddress::INVALID_MX_RECORD); $mailvalid->setMessage('email-dot-atom', Zend_Validate_EmailAddress::DOT_ATOM); $mailvalid->setMessage('email-quoted-string', Zend_Validate_EmailAddress::QUOTED_STRING); $mailvalid->setMessage('email-invalid-local-part', Zend_Validate_EmailAddress::INVALID_LOCAL_PART); $mailvalid->setMessage('email-length-exceeded', Zend_Validate_EmailAddress::LENGTH_EXCEEDED); $mailvalid->hostnameValidator->setMessage('hostname-invalid-hostname', Zend_Validate_Hostname::INVALID_HOSTNAME); $mailvalid->hostnameValidator->setMessage('hostname-local-name-not-allowed', Zend_Validate_Hostname::LOCAL_NAME_NOT_ALLOWED); $mailvalid->hostnameValidator->setMessage('hostname-unknown-tld', Zend_Validate_Hostname::UNKNOWN_TLD); $mailvalid->hostnameValidator->setMessage('hostname-invalid-local-name', Zend_Validate_Hostname::INVALID_LOCAL_NAME); $mailvalid->hostnameValidator->setMessage('hostname-undecipherable-tld', Zend_Validate_Hostname::UNDECIPHERABLE_TLD); // Clear div $clear = '<div class="clear"></div>'; // Headers $accountInformation = new Oibs_Form_Element_Note('accountinformation'); $accountInformation->setValue($clear . '<h3>Account information</h3>' . $clear); $personalInformation = new Oibs_Form_Element_Note('personalinformation'); $personalInformation->setValue('<h3>Personal Information</h3>' . $clear); $locationInformation = new Oibs_Form_Element_Note('locationinformation'); $locationInformation->setValue('<h3>Location Information</h3>' . $clear); $employmentInformation = new Oibs_Form_Element_Note('employmentinformation'); $employmentInformation->setValue('<h3>Employment Information</h3>' . $clear); $subscribeInformation = new Oibs_Form_Element_Note('subscribeinformation'); $subscribeInformation->setValue('<h3>Subscribe settings</h3>' . $clear); // Public text $publictext = 'Public'; // Username for description $auth = Zend_Auth::getInstance(); $identity = $auth->getIdentity(); $usernametext = $identity->username; $username = new Zend_Form_Element_Hidden('username'); $username->setLabel('Username')->setDescription($usernametext); $usernamepublic = new Zend_Form_Element_Hidden('username_publicity'); $usernamepublic->setLabel($publictext); $openid = new Zend_Form_Element_Text('openid'); $openid->setLabel('Open-ID')->setAttrib('id', 'open-ID')->addValidators(array(new Oibs_Validators_OpenidExists())); $openidclear = new Oibs_Form_Element_Note('openidclear'); $openidclear->setValue($clear); $password = new Zend_Form_Element_Password('password'); $password->setLabel('New password')->setAttrib('id', 'password')->addValidators(array(new Oibs_Validators_RepeatValidator('confirm_password'), array('NotEmpty', true, array('messages' => array('isEmpty' => 'Empty'))), array('StringLength', false, array(4, 22, 'messages' => array('stringLengthTooShort' => 'Password too short (4-22 characters)', 'stringLengthTooLong' => 'Password too long (4-22 characters)'))))); $passwordclear = new Oibs_Form_Element_Note('passwordclear'); $passwordclear->setValue($clear); $confirmpassword = new Zend_Form_Element_Password('confirm_password'); $confirmpassword->setLabel('Confirm password')->setAttrib('id', 'confirm-password')->addValidators(array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Empty'))), array('StringLength', false, array(4, 22, 'messages' => array('stringLengthTooShort' => 'Password too short (4-22 characters)', 'stringLengthTooLong' => 'Password too long (4-22 characters)'))))); $confirmpasswordclear = new Oibs_Form_Element_Note('confirm_passwordclear'); $confirmpasswordclear->setValue($clear); $email = new Zend_Form_Element_Text('email'); $email->setLabel('Email')->setAttrib('id', 'email')->setRequired(true)->addFilter('StringtoLower')->addValidators(array($mailvalid, array('NotEmpty', true, array('messages' => array('isEmpty' => 'Email empty'))), array('StringLength', false, array(6, 50, 'messages' => array('stringLengthTooShort' => 'Email too short (6-50 characters)', 'stringLengthTooLong' => 'Email too long (6-50 characters)'))))); $emailclear = new Oibs_Form_Element_Note('emailclear'); $emailclear->setValue($clear); $gravatar = new Zend_Form_Element_Hidden('gravatartext'); $gravatar->setLabel('Gravatar')->setDescription('<div style="text-align: right;">Enable <a href="http://www.gravatar.com">gravatar</a></div>'); $gravatarcheck = new Zend_Form_Element_Checkbox('gravatar'); $phone = new Zend_Form_Element_Text('phone'); $phone->setLabel('Phone')->setAttrib('id', 'phone'); $phonepublic = new Zend_Form_Element_Checkbox('phone_publicity'); $phonepublic->setLabel($publictext); $firstname = new Zend_Form_Element_Text('firstname'); $firstname->setLabel('First name')->setAttrib('id', 'first-name'); $firstnamepublic = new Zend_Form_Element_Checkbox('firstname_publicity'); $firstnamepublic->setLabel($publictext); // DB: surname $lastname = new Zend_Form_Element_Text('surname'); $lastname->setLabel('Last name')->setAttrib('id', 'last-name'); $lastnamepublic = new Zend_Form_Element_Checkbox('surname_publicity'); $lastnamepublic->setLabel($publictext); $gender = new Zend_Form_Element_Select('gender'); $gender->setLabel('Gender')->setAttrib('id', 'gender')->addMultiOptions(array('Select', 'Male', 'Female')); $genderpublic = new Zend_Form_Element_Checkbox('gender_publicity'); $genderpublic->setLabel($publictext); $birthday = new Zend_Form_Element_Text('birthday'); $birthday->setLabel('Date of Birth')->setAttrib('id', 'birthday')->setValidators(array(new Zend_Validate_Date('birthday'))); $birthdaypublic = new Zend_Form_Element_Checkbox('birthday_publicity'); $birthdaypublic->setLabel($publictext); $biography = new Zend_Form_Element_Textarea('biography'); $biography->setLabel('Biography')->setAttrib('id', 'biography')->setAttrib('rows', 30)->setAttrib('cols', 45)->addValidators(array(array('StringLength', false, array(0, 4000, 'messages' => array('stringLengthTooLong' => 'Biography too long'))))); //->setDescription('<div id="progressbar_biography" class="progress_ok"></div>'); $biographypublic = new Zend_Form_Element_Checkbox('biography_publicity'); $biographypublic->setLabel($publictext); $intereststext = new Oibs_Form_Element_Note('intereststext'); $intereststext->setValue('<div class="input-column1"></div>' . '<div class="input-column2 help">(Use commas to separate tags)</div><div class="clear"></div>'); $interests = new Zend_Form_Element_Text('interests'); $interests->setLabel('My interest (tags)')->setAttrib('id', 'interests'); $interestsclear = new Oibs_Form_Element_Note('interestsclear'); $interestsclear->setValue($clear); $weblinks_websites = new Oibs_Form_Element_Note('weblinks_websites'); $weblinks_websites->setValue('<div class="input-column-website1"><label><strong>Links to my websites:</strong></label></div>'); $weblinks_name = new Oibs_Form_Element_Note('weblinks_name'); $weblinks_name->setValue('<div class="input-column-website2">Name</div>'); $weblinks_url = new Oibs_Form_Element_Note('weblinks_url'); $weblinks_url->setValue('<div class="input-column-website3">Url</div><div class="clear"></div>'); $nameTooLongText = 'Name too long (max 45)'; $urlTooLongText = 'URL too long (max 150)'; $weblinks_name_site1 = new Zend_Form_Element_Text('weblinks_name_site1'); $weblinks_name_site1->setLabel('Web site 1')->setAttrib('id', 'website1-name')->addValidators(array(array('StringLength', false, array(0, 45, 'messages' => array('stringLengthTooLong' => $nameTooLongText))))); $weblinks_url_site1 = new Zend_Form_Element_Text('weblinks_url_site1'); $weblinks_url_site1->setAttrib('id', 'website1-url')->addValidators(array(new Oibs_Validators_UrlValidator(), array('StringLength', false, array(0, 150, 'messages' => array('stringLengthTooLong' => $urlTooLongText))))); $weblinks_name_site2 = new Zend_Form_Element_Text('weblinks_name_site2'); $weblinks_name_site2->setLabel('Web site 2')->setAttrib('id', 'website2-name')->addValidators(array(array('StringLength', false, array(0, 45, 'messages' => array('stringLengthTooLong' => $nameTooLongText))))); $weblinks_url_site2 = new Zend_Form_Element_Text('weblinks_url_site2'); $weblinks_url_site2->setAttrib('id', 'website2-url')->addValidators(array(new Oibs_Validators_UrlValidator(), array('StringLength', false, array(0, 150, 'messages' => array('stringLengthTooLong' => $urlTooLongText))))); $weblinks_name_site3 = new Zend_Form_Element_Text('weblinks_name_site3'); $weblinks_name_site3->setLabel('Web site 3')->setAttrib('id', 'website3-name')->setAttrib('id', 'website2-name')->addValidators(array(array('StringLength', false, array(0, 45, 'messages' => array('stringLengthTooLong' => $nameTooLongText))))); $weblinks_url_site3 = new Zend_Form_Element_Text('weblinks_url_site3'); $weblinks_url_site3->setAttrib('id', 'website3-url')->addValidators(array(new Oibs_Validators_UrlValidator(), array('StringLength', false, array(0, 150, 'messages' => array('stringLengthTooLong' => $urlTooLongText))))); $weblinks_name_site4 = new Zend_Form_Element_Text('weblinks_name_site4'); $weblinks_name_site4->setLabel('Web site 4')->setAttrib('id', 'website4-name')->setAttrib('id', 'website2-name')->addValidators(array(array('StringLength', false, array(0, 45, 'messages' => array('stringLengthTooLong' => $nameTooLongText))))); $weblinks_url_site4 = new Zend_Form_Element_Text('weblinks_url_site4'); $weblinks_url_site4->setAttrib('id', 'website4-url')->addValidators(array(new Oibs_Validators_UrlValidator(), array('StringLength', false, array(0, 150, 'messages' => array('stringLengthTooLong' => $urlTooLongText))))); $weblinks_name_site5 = new Zend_Form_Element_Text('weblinks_name_site5'); $weblinks_name_site5->setLabel('Web site 5')->setAttrib('id', 'website5-name')->setAttrib('id', 'website2-name')->addValidators(array(array('StringLength', false, array(0, 45, 'messages' => array('stringLengthTooLong' => $nameTooLongText))))); $weblinks_url_site5 = new Zend_Form_Element_Text('weblinks_url_site5'); $weblinks_url_site5->setAttrib('id', 'website5-url')->addValidators(array(new Oibs_Validators_UrlValidator(), array('StringLength', false, array(0, 150, 'messages' => array('stringLengthTooLong' => $urlTooLongText))))); $languages = new Default_Model_Languages(); $allLanguages = $languages->getAllNamesAndIds(); $userlanguage = new Zend_Form_Element_Select('userlanguage'); $userlanguage->setLabel('User interface language')->setAttrib('id', 'user-interface-language')->addMultiOption('', 'Select'); foreach ($allLanguages as $language) { $userlanguage->addMultiOption($language['id_lng'], $language['name_lng']); } $userlanguageclear = new Oibs_Form_Element_Note('userlanguageclear'); $userlanguageclear->setValue($clear); /* $avatar = new Zend_Form_Element_File('avatar'); $avatar->setLabel('Avatar image'); */ // DB: city $hometown = new Zend_Form_Element_Text('city'); $hometown->setLabel('Hometown')->setAttrib('id', 'hometown')->setRequired(true)->addValidators(array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Hometown empty'))), array('Regex', true, array('/^[\\p{L}0-9.\\- ]*$/')))); $hometownpublic = new Zend_Form_Element_Checkbox('city_publicity'); $hometownpublic->setLabel($publictext); $hometownpublic->helper = 'FormHidden'; $address = new Zend_Form_Element_Text('address'); $address->setLabel('Address')->setAttrib('id', 'address'); $addresspublic = new Zend_Form_Element_Checkbox('address_publicity'); $addresspublic->setLabel($publictext)->setAttrib('checked', 'checked')->setValue(1); $addresspublic->helper = 'FormHidden'; $country_model = new Default_Model_Countries(); $allCountries = $country_model->getAllCountries(); $usercountry = new Zend_Form_Element_Select('country'); $usercountry->setLabel('Country of Residence')->setAttrib('id', 'country')->addMultiOption('', 'Select'); foreach ($allCountries as $country) { $usercountry->addMultiOption($country['iso_ctr'], $country['printable_name_ctr']); } $usercountrypublic = new Zend_Form_Element_Checkbox('country_publicity'); $usercountrypublic->setLabel($publictext); $timezone_model = new Default_Model_Timezones(); $allTimezones = $timezone_model->getAllTimezones(); $usertimezone = new Zend_Form_Element_Select('usertimezone'); $usertimezone->setLabel('Time Zone')->setAttrib('id', 'time-zone')->addMultiOption('', 'Select'); foreach ($allTimezones as $timezone) { $usertimezone->addMultiOption($timezone['id_tmz'], $timezone['gmt_tmz'] . ' ' . $timezone['timezone_location_tmz']); } $usertimezonepublic = new Zend_Form_Element_Checkbox('usertimezone_publicity'); $usertimezonepublic->setLabel($publictext); $userProfilesModel = new Default_Model_UserProfiles(); $employments = $userProfilesModel->getEmployments(); $employments = array_merge(array('' => 'Select'), $employments); $employment = new Zend_Form_Element_Select('employment'); $employment->setLabel('I am currently')->setAttrib('id', 'status')->setRequired(true)->addMultiOptions($employments)->setErrorMessages(array('Select status')); $employmentpublic = new Zend_Form_Element_Checkbox('employment_publicity'); $employmentpublic->setLabel($publictext); // DB: company $employer_organization = new Zend_Form_Element_Text('company'); $employer_organization->setLabel('Employer / Organization')->setAttrib('id', 'employer-organization'); $employer_organizationpublic = new Zend_Form_Element_Checkbox('company_publicity'); $employer_organizationpublic->setLabel($publictext); //Subscribe things $favouritesModel = new Default_Model_UserHasFavourites(); $subscribeOptions = $favouritesModel->getFollows(); unset($subscribeOptions['8']); //Unsetting the translation box till its in use. //print_r($subscribeOptions);die; $test = new Zend_Form_Element_MultiCheckbox('lol'); //$test->setV $subscribeClasses = array("own_follows" => "Own contents", "fvr_follows" => "Favourite contents"); foreach ($subscribeClasses as $key => $value) { $subscribe[$key] = new Zend_Form_Element_MultiCheckbox($key); $subscribe[$key]->setLabel('Activities you want to follow in your ' . $value); $subscribe[$key]->addMultiOptions($subscribeOptions); } $subscribeclear = new Oibs_Form_Element_Note('subscribeclear'); $subscribeclear->setValue($clear); $save = new Zend_Form_Element_Submit('save'); $save->setLabel('Save profile')->setAttrib('id', 'save-profile')->setAttrib('class', 'submit-button'); $cancel = new Zend_Form_Element_Submit('cancel'); $cancel->setLabel('Cancel')->setAttrib('id', 'cancel')->setAttrib('class', 'submit-button'); $this->addElements(array($accountInformation, $username, $usernamepublic, $openid, $openidclear, $password, $passwordclear, $confirmpassword, $confirmpasswordclear, $personalInformation, $email, $emailclear, $gravatar, $gravatarcheck, $phone, $phonepublic, $firstname, $firstnamepublic, $lastname, $lastnamepublic, $gender, $genderpublic, $birthday, $birthdaypublic, $biography, $biographypublic, $weblinks_websites, $weblinks_name, $weblinks_url, $weblinks_name_site1, $weblinks_url_site1, $weblinks_name_site2, $weblinks_url_site2, $weblinks_name_site3, $weblinks_url_site3, $weblinks_name_site4, $weblinks_url_site4, $weblinks_name_site5, $weblinks_url_site5, $userlanguage, $userlanguageclear, $locationInformation, $hometown, $hometownpublic, $address, $addresspublic, $usercountry, $usercountrypublic, $usertimezone, $usertimezonepublic, $employmentInformation, $employment, $employmentpublic, $employer_organization, $employer_organizationpublic, $save, $cancel)); $accountInformation->setDecorators(array('ViewHelper')); $personalInformation->setDecorators(array('ViewHelper')); $locationInformation->setDecorators(array('ViewHelper')); $employmentInformation->setDecorators(array('ViewHelper')); $subscribeInformation->setDecorators(array('ViewHelper')); $username->setDecorators(array('InputDecorator')); $usernamepublic->setDecorators(array('PublicDecorator')); $openid->setDecorators(array('InputDecorator')); $openidclear->setDecorators(array('ViewHelper')); $password->setDecorators(array('InputDecorator')); $passwordclear->setDecorators(array('ViewHelper')); $confirmpassword->setDecorators(array('InputDecorator')); $confirmpasswordclear->setDecorators(array('ViewHelper')); $email->setDecorators(array('InputDecorator')); $emailclear->setDecorators(array('ViewHelper')); $gravatar->setDecorators(array('InputDecorator')); $gravatarcheck->setDecorators(array('PublicDecorator')); $phone->setDecorators(array('InputDecorator')); $phonepublic->setDecorators(array('PublicDecorator')); $firstname->setDecorators(array('InputDecorator')); $firstnamepublic->setDecorators(array('PublicDecorator')); $lastname->setDecorators(array('InputDecorator')); $lastnamepublic->setDecorators(array('PublicDecorator')); $gender->setDecorators(array('InputDecorator')); $genderpublic->setDecorators(array('PublicDecorator')); $birthday->setDecorators(array('InputDecorator')); $birthdaypublic->setDecorators(array('PublicDecorator')); $biography->setDecorators(array('InputDecorator')); $biographypublic->setDecorators(array('PublicDecorator')); $intereststext->setDecorators(array('ViewHelper')); $interests->setDecorators(array('InputDecorator')); $interestsclear->setDecorators(array('ViewHelper')); $weblinks_websites->setDecorators(array('ViewHelper')); $weblinks_name->setDecorators(array('ViewHelper')); $weblinks_url->setDecorators(array('ViewHelper')); $weblinks_name_site1->setDecorators(array('InputWebsiteNameDecorator')); $weblinks_url_site1->setDecorators(array('InputWebsiteUrlDecorator')); $weblinks_name_site2->setDecorators(array('InputWebsiteNameDecorator')); $weblinks_url_site2->setDecorators(array('InputWebsiteUrlDecorator')); $weblinks_name_site3->setDecorators(array('InputWebsiteNameDecorator')); $weblinks_url_site3->setDecorators(array('InputWebsiteUrlDecorator')); $weblinks_name_site4->setDecorators(array('InputWebsiteNameDecorator')); $weblinks_url_site4->setDecorators(array('InputWebsiteUrlDecorator')); $weblinks_name_site5->setDecorators(array('InputWebsiteNameDecorator')); $weblinks_url_site5->setDecorators(array('InputWebsiteUrlDecorator')); $userlanguage->setDecorators(array('InputDecorator')); $userlanguageclear->setDecorators(array('ViewHelper')); $hometown->setDecorators(array('InputDecorator')); $hometownpublic->setDecorators(array('PublicDecorator')); $address->setDecorators(array('InputDecorator')); $addresspublic->setDecorators(array('PublicDecorator')); $usercountry->setDecorators(array('InputDecorator')); $usercountrypublic->setDecorators(array('PublicDecorator')); $usertimezone->setDecorators(array('InputDecorator')); $usertimezonepublic->setDecorators(array('PublicDecorator')); $employment->setDecorators(array('InputDecorator')); $employmentpublic->setDecorators(array('PublicDecorator')); $employer_organization->setDecorators(array('InputDecorator')); $employer_organizationpublic->setDecorators(array('PublicDecorator')); $subscribe['own_follows']->setDecorators(array('InputDecorator')); $subscribe['fvr_follows']->setDecorators(array('InputDecorator')); $subscribeclear->setDecorators(array('ViewHelper')); $save->setDecorators(array('ViewHelper', array('HtmlTag', array('tag' => 'div', 'openOnly' => true, 'id' => 'save_changes')))); $cancel->setDecorators(array('ViewHelper', array('HtmlTag', array('tag' => 'div', 'closeOnly' => true)))); $this->setDecorators(array('FormElements', 'Form')); }
/** * * Edit User (admin only) * */ public function init() { $cname = explode('_', get_class()); $this->preInit(end($cname)); // use template file $this->setDecorators(array(array('ViewScript', array('viewScript' => 'forms/AdminUser.phtml')))); $request = Zend_Controller_Front::getInstance()->getRequest(); $request_profile_id = $request->getParam('id'); // get user from database $Profiles = new Application_Model_Profiles(); $ProfilesMeta = new Application_Model_ProfilesMeta(); $profile = $Profiles->getProfileByField('id', $request_profile_id); $all_meta = $ProfilesMeta->getMetaValues($profile->id); if (isset($all_meta['bulk_notifications'])) { $notifications_meta = json_decode($all_meta['bulk_notifications'], true); } // fields $role = new Zend_Form_Element_Select('role'); $role->setDecorators(array('ViewHelper', 'Errors'))->setMultiOptions(array('user' => 'User', 'subscriber' => 'Subscriber', 'reviewer' => 'Reviewer', 'admin' => 'Admin'))->setErrorMessages(array($this->translator->translate('User Role is requiered')))->setLabel($this->translator->translate('User Role'))->setRequired(true)->setValue($profile->role)->setAttrib('class', 'form-control'); $profile_id = new Zend_Form_Element_Text('id'); $profile_id->setDecorators(array('ViewHelper', 'Errors'))->setLabel($this->translator->translate('Id'))->setValue($profile->id)->setIgnore(true)->setAttrib('readonly', true)->setAttrib('class', 'form-control'); $username_minchars = Zend_Registry::get('config')->get('username_minchars'); $username_maxchars = Zend_Registry::get('config')->get('username_maxchars'); // lowercase, alnum without whitespaces $name = new Zend_Form_Element_Text('name'); $name->setDecorators(array('ViewHelper', 'Errors'))->setRequired(true)->addFilter('StringToLower')->addValidator('alnum', false, array('allowWhiteSpace' => false))->addValidator('stringLength', false, array($username_minchars, $username_maxchars))->setErrorMessages(array(sprintf($this->translator->translate('Please choose a valid username between %d and %d characters'), $username_minchars, $username_maxchars)))->setAttrib('class', 'form-control alnum-only')->setValue($profile->name)->setLabel($this->translator->translate('Name')); $email = new Zend_Form_Element_Text('email'); $email->setDecorators(array('ViewHelper', 'Errors'))->setLabel($this->translator->translate('Email'))->setValue($profile->email)->setAttrib('class', 'form-control'); $screenname = new Zend_Form_Element_Text('screen_name'); $screenname->setDecorators(array('ViewHelper', 'Errors'))->addFilter('StringTrim')->setValue($profile->screen_name)->addValidator('alnum', false, array('allowWhiteSpace' => true))->addValidator('stringLength', false, array($username_minchars, $username_maxchars))->setErrorMessages(array(sprintf($this->translator->translate('Please choose a valid name between %d and %d characters'), $username_minchars, $username_maxchars)))->setLabel($this->translator->translate('Screen Name'))->setRequired(true)->setAttrib('class', 'form-control'); $description = new Zend_Form_Element_Textarea('description'); $description->setDecorators(array('ViewHelper', 'Errors'))->setAttrib('COLS', '')->setAttrib('ROWS', '4')->setValue(isset($all_meta['description']) ? $all_meta['description'] : '')->setLabel($this->translator->translate('Description'))->setAttrib('class', 'form-control'); $profile_privacy = new Zend_Form_Element_Select('profile_privacy'); $profile_privacy->setDecorators(array('ViewHelper', 'Errors'))->setMultiOptions(Zend_Registry::get('profile_privacy_all'))->setErrorMessages(array($this->translator->translate('Select profile visibility')))->setLabel($this->translator->translate('Profile visibility'))->setRequired(true)->setValue($profile->profile_privacy)->setAttrib('class', 'form-control'); $default_privacy = new Zend_Form_Element_Select('default_privacy'); $default_privacy->setDecorators(array('ViewHelper', 'Errors'))->setMultiOptions(Zend_Registry::get('post_privacy_array'))->setLabel($this->translator->translate('Default visibility'))->setRequired(true)->setValue($profile->default_privacy)->setAttrib('class', 'form-control'); $language = new Zend_Form_Element_Select('language'); $language->setDecorators(array('ViewHelper', 'Errors'))->setMultiOptions(Zend_Registry::get('languages_array'))->setLabel($this->translator->translate('Language'))->setRequired(true)->setValue($profile->language)->setAttrib('class', 'form-control'); $birthday = new Application_Form_Element_Date('birthday'); $birthday->setDecorators(array('ViewHelper', 'Errors'))->setLabel($this->translator->translate('Date of birth'))->setErrorMessages(array($this->translator->translate('Please enter a valid date'))); $birthday->setYearSpan(1920, date('Y') - 1); if (isset($all_meta['birthday'])) { $timestamp = strtotime($all_meta['birthday']); $birthday->setValue(array('day' => date('d', $timestamp), 'month' => date('m', $timestamp), 'year' => date('Y', $timestamp))); } $password1 = new Zend_Form_Element_Password('password1'); $password1->setDecorators(array('ViewHelper', 'Errors'))->setAttrib('autocomplete', 'off')->setLabel($this->translator->translate('New Password:'******'class', 'form-control'); $activation = new Zend_Form_Element_Text('activationkey'); $activation->setDecorators(array('ViewHelper', 'Errors'))->setLabel($this->translator->translate('Activation key (or "activated")'))->setValue($profile->activationkey)->setAttrib('class', 'form-control'); $gender = new Zend_Form_Element_Select('gender'); $gender->setDecorators(array('ViewHelper', 'Errors'))->setMultiOptions(Zend_Registry::get('genders_array'))->setErrorMessages(array($this->translator->translate('Please select something')))->setLabel($this->translator->translate('Gender'))->setRequired(true)->setValue(isset($all_meta['gender']) ? $all_meta['gender'] : '')->setAttrib('class', 'form-control'); $online_status = new Zend_Form_Element_Select('show_online_status'); $online_status->setDecorators(array('ViewHelper', 'Errors'))->setMultiOptions(Zend_Registry::get('onlinestatus_array'))->setErrorMessages(array($this->translator->translate('Select profile visibility')))->setLabel($this->translator->translate('Online Status'))->setRequired(true)->setValue(isset($all_meta['show_online_status']) ? $all_meta['show_online_status'] : 's')->setAttrib('class', 'form-control'); $contact_privacy = new Zend_Form_Element_Select('contact_privacy'); $contact_privacy->setDecorators(array('ViewHelper', 'Errors'))->setMultiOptions(Zend_Registry::get('contactprivacy_array'))->setErrorMessages(array($this->translator->translate('Please select something')))->setLabel($this->translator->translate('Who can contact me?'))->setRequired(true)->setValue(isset($all_meta['contact_privacy']) ? $all_meta['contact_privacy'] : 'e')->setAttrib('class', 'form-control'); $location = new Zend_Form_Element_Text('location'); $location->setDecorators(array('ViewHelper', 'Errors'))->setRequired(false)->setLabel($this->translator->translate('Location'))->setAttrib('class', 'form-control')->addFilter('StripTags')->setValue(isset($all_meta['location']) ? $all_meta['location'] : '')->setErrorMessages(array($this->translator->translate('Enter a valid location'))); $website = new Zend_Form_Element_Text('website'); $website->setDecorators(array('ViewHelper', 'Errors'))->setRequired(false)->setLabel($this->translator->translate('Website'))->setAttrib('class', 'form-control')->addFilter('StripTags')->setValue(isset($all_meta['website']) ? $all_meta['website'] : '')->setErrorMessages(array($this->translator->translate('Enter a valid website'))); $badges = new Zend_Form_Element_Text('badges'); $badges->setDecorators(array('ViewHelper', 'Errors'))->setLabel($this->translator->translate('Badges based on Glyphicon font separated by comma (e.g. "bullhorn,earphone")'))->setValue(isset($all_meta['badges']) ? $all_meta['badges'] : '')->setAttrib('class', 'form-control'); $n1 = new Zend_Form_Element_Checkbox('notification_email_1'); $n1->setDecorators(array('ViewHelper', 'Errors'))->setValue(isset($notifications_meta['notification_email_1']) && $notifications_meta['notification_email_1'] == 1 ? 1 : 0)->setLabel($this->translator->translate('Email when someone posts a new comment'))->setCheckedValue("1")->setUncheckedValue("0"); $n2 = new Zend_Form_Element_Checkbox('notification_email_2'); $n2->setDecorators(array('ViewHelper', 'Errors'))->setValue(isset($notifications_meta['notification_email_2']) && $notifications_meta['notification_email_2'] == 1 ? 1 : 0)->setLabel($this->translator->translate('Email when someone likes your post'))->setCheckedValue("1")->setUncheckedValue("0"); $n3 = new Zend_Form_Element_Checkbox('notification_email_3'); $n3->setDecorators(array('ViewHelper', 'Errors'))->setValue(isset($notifications_meta['notification_email_3']) && $notifications_meta['notification_email_3'] == 1 ? 1 : 0)->setLabel($this->translator->translate('Email when someone follows you'))->setCheckedValue("1")->setUncheckedValue("0"); $n4 = new Zend_Form_Element_Checkbox('notification_email_4'); $n4->setDecorators(array('ViewHelper', 'Errors'))->setValue(isset($notifications_meta['notification_email_4']) && $notifications_meta['notification_email_4'] == 1 ? 1 : 0)->setLabel($this->translator->translate('Email on new friends'))->setCheckedValue("1")->setUncheckedValue("0"); $n6 = new Zend_Form_Element_Checkbox('notification_email_6'); $n6->setDecorators(array('ViewHelper', 'Errors'))->setValue(isset($notifications_meta['notification_email_6']) && $notifications_meta['notification_email_6'] == 1 ? 1 : 0)->setLabel($this->translator->translate('Email when you lose a follower'))->setCheckedValue("1")->setUncheckedValue("0"); $n7 = new Zend_Form_Element_Checkbox('notification_email_7'); $n7->setDecorators(array('ViewHelper', 'Errors'))->setValue(isset($notifications_meta['notification_email_7']) && $notifications_meta['notification_email_7'] == 1 ? 1 : 0)->setLabel($this->translator->translate('Email when someone posts on your wall'))->setCheckedValue("1")->setUncheckedValue("0"); $n8 = new Zend_Form_Element_Checkbox('notification_email_8'); $n8->setDecorators(array('ViewHelper', 'Errors'))->setValue(isset($notifications_meta['notification_email_8']) && $notifications_meta['notification_email_8'] == 1 ? 1 : 0)->setLabel($this->translator->translate('Email when someone sends you a private message'))->setCheckedValue("1")->setUncheckedValue("0"); $is_hidden = new Zend_Form_Element_Checkbox('is_hidden'); $is_hidden->setDecorators(array('ViewHelper', 'Errors'))->setValue(isset($profile->is_hidden) && $profile->is_hidden == 1 ? 1 : 0)->setLabel($this->translator->translate('Hide?'))->setCheckedValue("1")->setUncheckedValue("0"); $submit = new Zend_Form_Element_Submit('formsubmit'); $submit->setDecorators(array('ViewHelper'))->setLabel($this->translator->translate('Save'))->setAttrib('class', 'submit btn btn-default'); $this->addElements(array($profile_id, $role, $name, $email, $screenname, $description, $profile_privacy, $default_privacy, $language, $gender, $online_status, $contact_privacy, $location, $website, $birthday, $password1, $activation, $badges, $n1, $n2, $n3, $n4, $n6, $n7, $n8, $is_hidden, $submit)); $this->postInit(); }
public function init() { $this->setDisableLoadDefaultDecorators(true); $this->setName('venta')->setAttrib('class', 'form-horizontal')->setAttrib('enctype', 'multipart/form-data'); //local al que pertenece el usuario $userInfo = Zend_Auth::getInstance()->getStorage()->read(); $usuariohaslocales = new Application_Model_DbTable_UsuarioHasLocal(); $uhl = $usuariohaslocales->localVendedorUsuario($userInfo->usu_id_usuario); $local = $uhl[0]['loc_nombre']; $loc_nombre = new Zend_Form_Element_Hidden('loc_nombre'); $loc_nombre->setValue($local); // * * * * * * * * ASIGNAR VENDEDOR (TAB 1) * * * * * * * * * * $usu_id_usuario = new Zend_Form_Element_Select('usu_id_usuario'); $usu_id_usuario->setAttrib('class', 'input-large primero'); $usu_id_usuario->setDecorators(array(array('ViewHelper'))); $filaVendedor = new Application_Model_DbTable_Usuarios(); foreach ($filaVendedor->getUsuarioPorPerfilLocal("Vendedor Fijo", $local) as $vendedor) { $usu_id_usuario->addMultiOption($vendedor->usu_id_usuario, $vendedor->usu_nombre . ' ' . $vendedor->usu_apellido_1 . ' ' . $vendedor->usu_apellido_2); } foreach ($filaVendedor->getUsuarioPorPerfilLocal("Vendedor Auxiliar", $local) as $vendedor) { $usu_id_usuario->addMultiOption($vendedor->usu_id_usuario, $vendedor->usu_nombre . ' ' . $vendedor->usu_apellido_1 . ' ' . $vendedor->usu_apellido_2); } // * * * * * AGREGAR FILA DE MERCADERIA A LA VENTA (TAB 2)* * * * * $mer_codigo = new Zend_Form_Element_Text('mer_codigo'); $mer_codigo->setDecorators(array(array('ViewHelper'))); $mer_codigo->setAttrib("tabindex", "1"); $mer_codigo->setAttrib("class", "input-small jumper1 primero"); $btn_mer_codigo = new Zend_Form_Element_Button('btn_mer_codigo'); $btn_mer_codigo->setAttrib('class', 'btn jumper1')->setAttrib('onClick', 'getDataMercaderia()'); $btn_mer_codigo->setLabel('<i class="icon-arrow-right"></i>')->setAttrib('escape', false); $btn_mer_codigo->setDecorators(array(array('ViewHelper'))); $btn_mer_codigo->setAttrib("tabindex", "2"); $f_num_mercaderia = new Zend_Form_Element_Text('f_num_mercaderia'); $f_num_mercaderia->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim'); $f_num_mercaderia->setAttrib('class', 'input-mini jumper1'); $f_num_mercaderia->setAttrib('onchange', 'calcularTotalMonto()'); $f_num_mercaderia->setValue('1'); $f_num_mercaderia->setDecorators(array(array('ViewHelper'))); $f_num_mercaderia->setAttrib("tabindex", "3"); $mer_articulo = new Zend_Form_Element_Text('mer_articulo'); $mer_articulo->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim'); $mer_articulo->setAttrib('class', 'input-small disabled')->setAttrib('readonly', 'readonly'); $mer_articulo->setDecorators(array(array('ViewHelper'))); $col_nombre = new Zend_Form_Element_Text('col_nombre'); $col_nombre->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim'); $col_nombre->setAttrib('class', 'input-small disabled')->setAttrib('readonly', 'readonly'); $col_nombre->setDecorators(array(array('ViewHelper'))); $mer_foto = new Zend_Form_Element_Hidden('mer_foto'); $mer_foto->setValue(''); $hme_precio = new Zend_Form_Element_Text('hme_precio'); $hme_precio->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim'); $hme_precio->setAttrib('class', 'input-small disabled')->setAttrib('readonly', 'readonly'); $hme_precio->setDecorators(array(array('ViewHelper'))); //total de mercaderia -> input que no es del formulario, se actualiza con javascript $f_total_mercaderia = new Zend_Form_Element_Text('f_total_mercaderia'); $f_total_mercaderia->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim'); $f_total_mercaderia->setAttrib('class', 'input-small disabled')->setAttrib('readonly', 'readonly'); $f_total_mercaderia->setDecorators(array(array('ViewHelper'))); // * * * * * * * * FORMA DE PAGO (TAB 3) * * * * * * * * * * $tip_id_tipo_pago = new Zend_Form_Element_Select('tip_id_tipo_pago'); $tip_id_tipo_pago->setAttrib('class', 'input-large primero jumper2')->setAttrib('onChange', 'calcularPago()')->setAttrib("tabindex", "1"); $filaTipoPago = new Application_Model_DbTable_Tipopago(); foreach ($filaTipoPago->fetchAll() as $tipoPago) { $tip_id_tipo_pago->addMultiOption($tipoPago->tip_id_tipo_pago, $tipoPago->tip_nombre); } $tip_id_tipo_pago->setDecorators(array(array('ViewHelper'))); $f_pago_monto = new Zend_Form_Element_Text('f_pago_monto'); $f_pago_monto->setRequired(true); $f_pago_monto->setAttrib('class', 'input-medium jumper2')->setAttrib('onChange', 'calcularVuelto()')->setAttrib("tabindex", "2"); $f_pago_monto->setDecorators(array(array('ViewHelper'))); // * * * * * * * * FORMA DE PAGO EXTRA (TAB 3) * * * * * * * * * * $tphv_codigo_cheque = new Zend_Form_Element_Text('tphv_codigo_cheque'); $tphv_codigo_cheque->setAttrib('class', 'input-large jumper2')->setAttrib("tabindex", "3"); $tphv_codigo_cheque->setDecorators(array(array('ViewHelper'))); $tphv_cant_cuotas = new Zend_Form_Element_Select('tphv_cant_cuotas'); $tphv_cant_cuotas->setAttrib('class', 'input-large jumper2')->setAttrib('onChange', 'calcularMontoCuotas()')->setAttrib("tabindex", "3"); $tphv_cant_cuotas->addMultiOption("0", "-"); $tphv_cant_cuotas->addMultiOption("1", "1 Cuota"); $tphv_cant_cuotas->addMultiOption("2", "2 Cuotas"); $tphv_cant_cuotas->addMultiOption("3", "3 Cuotas"); $tphv_cant_cuotas->setDecorators(array(array('ViewHelper'))); $f_monto_cuota = new Zend_Form_Element_Text('f_monto_cuota'); $f_monto_cuota->setAttrib('class', 'disabled input-large')->setAttrib('readonly', 'readonly'); $f_monto_cuota->setDecorators(array(array('ViewHelper'))); $tphv_observacion_smo = new Zend_Form_Element_Textarea('tphv_observacion_smo'); $tphv_observacion_smo->setAttrib('class', 'input-large jumper2')->setAttrib('rows', '2')->setAttrib('onChange', 'calcularMontoCuotas()')->setAttrib("tabindex", "4"); $tphv_observacion_smo->setDecorators(array(array('ViewHelper'))); // * * * * * * * * APLICAR DESCUENTO (TAB 4) * * * * * * * * * * $des_id_descuento = new Zend_Form_Element_Select('des_id_descuento'); $des_id_descuento->setAttrib('class', 'input-large primero jumper3')->setAttrib('onChange', 'calcularDescuento()'); $filaDcto = new Application_Model_DbTable_Descuento(); foreach ($filaDcto->fetchAll() as $dcto) { $des_id_descuento->addMultiOption($dcto->des_id_descuento, $dcto->des_tipo . ' (' . $dcto->des_porcentaje . '%)'); } $des_id_descuento->setAttrib("tabindex", "1")->setDecorators(array(array('ViewHelper'))); $f_descuento_monto = new Zend_Form_Element_Text('f_descuento_monto'); $f_descuento_monto->setRequired(true)->setValue("0"); $f_descuento_monto->setAttrib('class', 'input-medium jumper3'); $f_descuento_monto->setAttrib("tabindex", "2")->setDecorators(array(array('ViewHelper'))); // * * * * * * * * SUBTOTALES DE LA VENTA (ABAJO DE TABS) * * * * * * * * $f_total = new Zend_Form_Element_Text('f_total'); $f_total->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim'); $f_total->setAttrib('class', 'disabled input-small')->setAttrib('readonly', 'readonly'); $f_total->setDecorators(array(array('ViewHelper'))); $f_dcto = new Zend_Form_Element_Text('f_dcto'); $f_dcto->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim'); $f_dcto->setAttrib('class', 'disabled input-small')->setAttrib('readonly', 'readonly'); $f_dcto->setDecorators(array(array('ViewHelper'))); $f_vuelto = new Zend_Form_Element_Text('f_vuelto'); $f_vuelto->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim'); $f_vuelto->setAttrib('class', 'disabled input-small')->setAttrib('readonly', 'readonly'); $f_vuelto->setDecorators(array(array('ViewHelper'))); $f_total_final = new Zend_Form_Element_Text('f_total_final'); $f_total_final->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim'); $f_total_final->setAttrib('class', 'disabled input-small')->setAttrib('readonly', 'readonly'); $f_total_final->setDecorators(array(array('ViewHelper'))); // * * * * * * * * SUBMIT * * * * * * * * //LISTA DE INVENTARIO AGREGADO (STRING) $stringMercanciaInput = new Zend_Form_Element_Hidden('stringMercanciaInput'); $stringMercanciaInput->setValue(''); $submit = new Zend_Form_Element_Submit('submit'); $submit->setAttrib('id', 'submitbutton'); $submit->setAttrib('class', 'btn btn-large btn-primary btn-block primero'); $submit->setLabel('F I N A L I Z A R V E N T A'); $submit->setDecorators(array(array('ViewHelper'))); $controllerFront = Zend_Controller_Front::getInstance(); $returnUrl = $controllerFront->getRequest()->getHeader('REFERER'); $this->addElement('hidden', 'returnUrl', array('value' => $returnUrl)); $this->addElements(array($loc_nombre, $usu_id_usuario, $mer_codigo, $btn_mer_codigo, $f_num_mercaderia, $mer_articulo, $col_nombre, $mer_foto, $hme_precio, $f_total_mercaderia, $tip_id_tipo_pago, $f_pago_monto, $tphv_codigo_cheque, $tphv_cant_cuotas, $f_monto_cuota, $tphv_observacion_smo, $des_id_descuento, $f_descuento_monto, $f_total, $f_dcto, $f_vuelto, $f_total_final, $stringMercanciaInput, $submit)); }
/** * @author code generate * @return mixed */ public function __construct($option = array()) { $userId = new Zend_Form_Element_Hidden('TutorId'); $userId->setDecorators(array('ViewHelper')); $this->addElement($userId); $birthDay = new Zend_Form_Element_Text('Birthday'); $birthDay->setLabel('Ngày sinh *'); $birthDay->addFilter('StringTrim'); $birthDay->setRequired(true); $birthDay->setDecorators(array('ViewHelper', array(array('control' => 'HtmlTag'), array('tag' => 'div', 'class' => 'element-control')), array('Label', array('class' => 'col-lg-2 control-label')), array(array('controls' => 'HtmlTag'), array('tag' => 'div', 'class' => 'form-group')))); $birthDay->addValidator('stringLength', false, array(2, 50, "messages" => "Ngày sinh dài tối đa 50 ký tự")); $this->addElement($birthDay); $gender = new Zend_Form_Element_Select('Gender'); $gender->setLabel('Giới tính *'); $gender->addFilter('StringTrim'); $gender->setRequired(true); $gender->setMultiOptions(array('1' => 'Nam', '0' => 'Nữ')); $gender->setDecorators(array('ViewHelper', array(array('control' => 'HtmlTag'), array('tag' => 'div', 'class' => 'element-control')), array('Label', array('class' => 'control-label')), array(array('controls' => 'HtmlTag'), array('tag' => 'div', 'class' => 'form-group')))); $gender->setSeparator(''); $gender->setValue("1"); $this->addElement($gender); $email = new Zend_Form_Element_Text('Email'); $email->setLabel('Email *'); $email->addFilter('StringTrim'); $email->setRequired(true); $email->setDecorators(array('ViewHelper', array(array('control' => 'HtmlTag'), array('tag' => 'div', 'class' => 'element-control')), array('Label', array('class' => 'col-lg-2 control-label')), array(array('controls' => 'HtmlTag'), array('tag' => 'div', 'class' => 'form-group')))); $email->addValidator(new Zend_Validate_Db_NoRecordExists("Tutors", "Email")); $email->addValidator('EmailAddress', true); $email->setRequired(true)->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => "Email không phù hợp"))); $this->addElement($email); $userName = new Zend_Form_Element_Text('UserName'); $userName->setLabel('Họ tên *'); $userName->addFilter('StringTrim'); $userName->setRequired(true); $userName->setDecorators(array('ViewHelper', array(array('control' => 'HtmlTag'), array('tag' => 'div', 'class' => 'element-control')), array('Label', array('class' => 'col-lg-2 control-label')), array(array('controls' => 'HtmlTag'), array('tag' => 'div', 'class' => 'form-group')))); $userName->addValidator('stringLength', false, array(2, 50, "messages" => "Họ tên dài tối đa 2-50 ký tự")); $this->addElement($userName); $address = new Zend_Form_Element_Text('Address'); $address->setLabel('Địa chỉ *'); $address->addFilter('StringTrim'); $address->setRequired(true); $address->setDecorators(array('ViewHelper', array(array('control' => 'HtmlTag'), array('tag' => 'div', 'class' => 'element-control')), array('Label', array('class' => 'col-lg-2 control-label')), array(array('controls' => 'HtmlTag'), array('tag' => 'div', 'class' => 'form-group')))); $userName->addValidator('stringLength', false, array(1, 100, "messages" => "Địa chỉ dài tối đa 100 ký tự")); $this->addElement($address); $phone = new Zend_Form_Element_Text('Phone'); $phone->setLabel('Điện thoại *'); $phone->addFilter('StringTrim'); $phone->setRequired(true); $phone->setDecorators(array('ViewHelper', array(array('control' => 'HtmlTag'), array('tag' => 'div', 'class' => 'element-control')), array('Label', array('class' => 'col-lg-2 control-label')), array(array('controls' => 'HtmlTag'), array('tag' => 'div', 'class' => 'form-group')))); $phone->addValidator('stringLength', false, array(6, 50, "messages" => "Điện thoại dài tối đa 6-50 ký tự")); $this->addElement($phone); $required = new Zend_Validate_NotEmpty(); $required->setType($required->getType() | Zend_Validate_NotEmpty::INTEGER | Zend_Validate_NotEmpty::ZERO); $level = new Zend_Form_Element_Select('Level'); $level->setLabel('Trình độ *'); $level->addFilter('StringTrim'); $level->addValidator('Int'); $level->setRequired(true); $level->setDecorators(array('ViewHelper', array(array('control' => 'HtmlTag'), array('tag' => 'div', 'class' => 'element-control')), array('Label', array('class' => 'control-label')), array(array('controls' => 'HtmlTag'), array('tag' => 'div', 'class' => 'form-group')))); $level->addValidators(array($required)); $level->setMultiOptions(unserialize(TUTOR_LEVELS)); $this->addElement($level); $university = new Zend_Form_Element_Text('University'); $university->setLabel('Trường tốt nghiệp *'); $university->addFilter('StringTrim'); $university->setRequired(true); $university->setDecorators(array('ViewHelper', array(array('control' => 'HtmlTag'), array('tag' => 'div', 'class' => 'element-control')), array('Label', array('class' => 'control-label')), array(array('controls' => 'HtmlTag'), array('tag' => 'div', 'class' => 'form-group')))); $university->addValidator('stringLength', false, array(1, 100, "messages" => "Trường tố nghiệp dài tối đa 100 ký tự")); $this->addElement($university); $subject = new Zend_Form_Element_Text('Subject'); $subject->setLabel('Chuyên ngành *'); $subject->addFilter('StringTrim'); $subject->setRequired(true); $subject->setDecorators(array('ViewHelper', array(array('control' => 'HtmlTag'), array('tag' => 'div', 'class' => 'element-control')), array('Label', array('class' => 'control-label')), array(array('controls' => 'HtmlTag'), array('tag' => 'div', 'class' => 'form-group')))); $subject->addValidator('stringLength', false, array(1, 100, "messages" => "Chuyên ngành dài tối đa 100 ký tự")); $this->addElement($subject); $experienceYears = new Zend_Form_Element_Select('ExperienceYears'); $experienceYears->setLabel('Số Năm Kinh Nghiệm *'); $experienceYears->addFilter('StringTrim'); $experienceYears->setRequired(false); $experienceYears->setDecorators(array('ViewHelper', array(array('control' => 'HtmlTag'), array('tag' => 'div', 'class' => 'element-control')), array('Label', array('class' => 'control-label')), array(array('controls' => 'HtmlTag'), array('tag' => 'div', 'class' => 'form-group')))); $options = unserialize(EXPERIENCE_YEAR); //$experienceYears->addMultiOptions(array_combine($options, $options)); $experienceYears->setMultiOptions(unserialize(EXPERIENCE_YEAR)); $this->addElement($experienceYears); $career = new Zend_Form_Element_Select('Career'); $career->setLabel('Hiện tại là *'); $career->addFilter('StringTrim'); $career->addValidator('Int'); $career->setRequired(true); $career->setDecorators(array('ViewHelper', array(array('control' => 'HtmlTag'), array('tag' => 'div', 'class' => 'element-control')), array('Label', array('class' => 'control-label')), array(array('controls' => 'HtmlTag'), array('tag' => 'div', 'class' => 'form-group')))); $career->setMultiOptions(unserialize(TUTOR_CAREERS)); $this->addElement($career); $careerLocation = new Zend_Form_Element_Text('CareerLocation'); $careerLocation->setLabel('Nơi Công Tác ( Giáo hoặc Giảng Viên ) *'); $careerLocation->addFilter('StringTrim'); $careerLocation->setRequired(false); $careerLocation->setAttrib('style', 'min-height: 30px;'); $careerLocation->setDecorators(array('ViewHelper', array(array('control' => 'HtmlTag'), array('tag' => 'div', 'class' => 'element-control')), array('Label', array('class' => 'control-label')), array(array('controls' => 'HtmlTag'), array('tag' => 'div', 'class' => 'form-group')))); $careerLocation->addValidator('stringLength', false, array(1, 100, "messages" => "Nơi Công Tác dài tối đa 100 ký tự")); $this->addElement($careerLocation); $teachableInClass = new Zend_Form_Element_Text('TeachableInClass'); $teachableInClass->setLabel('Lớp Có Thể Dạy'); $teachableInClass->addFilter('StringTrim'); $teachableInClass->setRequired(false); $teachableInClass->setAttrib('disabled', true); $teachableInClass->setDescription('<a id="grades-modal" class="btn btn-info" title="Chọn lớp">...</a>'); $teachableInClass->setDecorators(array('ViewHelper', array('Description', array('escape' => false)), array(array('control' => 'HtmlTag'), array('tag' => 'div', 'class' => 'element-control col-lg-6')), array('Label', array('class' => 'control-label col-lg-2')), array(array('controls' => 'HtmlTag'), array('tag' => 'div', 'class' => 'form-group')))); $this->addElement($teachableInClass); $teachableSubjects = new Zend_Form_Element_Text('TeachableSubjects'); $teachableSubjects->setLabel('Môn Có Thể Dạy'); $teachableSubjects->addFilter('StringTrim'); $teachableSubjects->setRequired(false); $teachableSubjects->setAttrib('disabled', true); $teachableSubjects->setDescription('<a id="subjects-modal" class="btn btn-info" title="Chọn môn">...</a>'); $teachableSubjects->setDecorators(array('ViewHelper', array('Description', array('escape' => false)), array(array('control' => 'HtmlTag'), array('tag' => 'div', 'class' => 'element-control col-lg-6')), array('Label', array('class' => 'control-label col-lg-2')), array(array('controls' => 'HtmlTag'), array('tag' => 'div', 'class' => 'form-group')))); $this->addElement($teachableSubjects); $teachableDistricts = new Zend_Form_Element_Text('TeachableDistricts'); $teachableDistricts->setLabel('Khu Vực Có Thể Dạy'); $teachableDistricts->addFilter('StringTrim'); $teachableDistricts->setRequired(false); $teachableDistricts->setAttrib('disabled', true); $teachableDistricts->setDescription('<span id="districts-modal" class="btn btn-info" title="Chọn quận">...</span>'); $teachableDistricts->setDecorators(array('ViewHelper', array('Description', array('escape' => false)), array(array('control' => 'HtmlTag'), array('tag' => 'div', 'class' => 'element-control col-lg-6')), array('Label', array('class' => 'control-label col-lg-2')), array(array('controls' => 'HtmlTag'), array('tag' => 'div', 'class' => 'form-group')))); $this->addElement($teachableDistricts); $avatar = new Zend_Form_Element_Hidden('Upload'); $avatar->setLabel('Hình đại diện'); $avatar->setRequired(false); $avatar->setDescription('fieldlabel'); $avatar->setDecorators(array('ViewHelper', array(array('Description' => 'HtmlTag'), array('tag' => 'div', 'id' => "file-uploader")), array(array('Errors' => 'HtmlTag'), array('placement' => 'append', 'tag' => 'img', 'id' => 'progress-img', 'src' => "/scripts/upload/loading.gif")), array(array('control' => 'HtmlTag'), array('tag' => 'div', 'class' => 'element-control', 'style' => "position: relative;float: left;margin-left: 20px;")), array('Label', array('class' => 'control-label')), array(array('controls' => 'HtmlTag'), array('tag' => 'div', 'class' => 'form-group')))); $this->addElement($avatar); $avatarNote = new Zend_Form_Element_Hidden('Avatar'); $avatarNote->setLabel('Chú ý'); $avatarNote->setRequired(false); $avatarNote->setDescription("Kích thước khoảng: 240 x 120 (px)<br>Kích cỡ cho phép: " . IMAGE_SIZE_LIMIT . " kB"); $avatarNote->setDecorators(array('ViewHelper', array('Description', array('escape' => false, 'tag' => 'div')), array(array('control' => 'HtmlTag'), array('tag' => 'div', 'class' => 'element-control')), array('Label', array('class' => 'control-label')), array(array('controls' => 'HtmlTag'), array('tag' => 'div', 'class' => 'form-group', 'style' => "float: left;")))); $this->addElement($avatarNote); $introduction = new Zend_Form_Element_Textarea('Introduction'); $introduction->setLabel('Giới thiệu bản thân'); $introduction->addFilter('StringTrim'); $introduction->setRequired(false); $introduction->setOptions(array('cols' => '10', 'rows' => '4')); /* $introduction->setDecorators(array('ViewHelper')); */ $introduction->setDecorators(array('ViewHelper', array(array('control' => 'HtmlTag'), array('tag' => 'div', 'class' => 'element-control')), array('Label', array('class' => 'control-label')), array(array('controls' => 'HtmlTag'), array('tag' => 'div', 'class' => 'form-group')))); $subject->addValidator('stringLength', false, array(1, 2000, "messages" => "Giới thiệu bản thân dài tối đa 2000 ký tự")); $this->addElement($introduction); $isDisabled = new Zend_Form_Element_Text('IsDisabled'); $isDisabled->setLabel('IsDisabled'); $isDisabled->addFilter('StringTrim'); $isDisabled->addValidator('Int'); $isDisabled->setDecorators(array('ViewHelper', array(array('control' => 'HtmlTag'), array('tag' => 'div', 'class' => 'element-control')), array('Label', array('class' => 'control-label')), array(array('controls' => 'HtmlTag'), array('tag' => 'div', 'class' => 'form-group')))); $this->addElement($isDisabled); $submit = new Zend_Form_Element_Submit('Save'); $submit->setLabel('Đăng ký'); $submit->setAttrib('class', 'btn btn-primary'); $submit->setDecorators(array('ViewHelper')); $this->addElement($submit); $reset = new Zend_Form_Element_Reset('Reset'); $reset->setLabel('Làm lại'); $reset->setAttrib('class', 'btn btn-primary'); $reset->setDecorators(array('ViewHelper')); $this->addElement($reset); $this->addDisplayGroup(array('UserName', 'Gender', 'Birthday', 'Email', 'Address', 'Phone'), 'contact', array('disableLoadDefaultDecorators' => false, 'legend' => 'Thông tin cá nhân')); $contact = $this->getDisplayGroup('contact'); $contact->setDecorators(array('FormElements', 'Fieldset', array('HtmlTag', array('tag' => 'fieldset', 'class' => 'well the-fieldset')))); $this->addDisplayGroup(array('Level', 'University', 'Subject', 'Career', 'CareerLocation', 'ExperienceYears'), 'level', array('disableLoadDefaultDecorators' => false, 'legend' => 'Thông tin học vấn')); $level = $this->getDisplayGroup('level'); $level->setDecorators(array('FormElements', 'Fieldset', array('HtmlTag', array('tag' => 'fieldset', 'class' => 'well the-fieldset')))); $this->addDisplayGroup(array('TeachableInClass', 'TeachableSubjects', 'TeachableDistricts', 'Upload', 'Avatar', 'Introduction'), 'extra', array('disableLoadDefaultDecorators' => false, 'legend' => 'Thông tin thêm')); $extra = $this->getDisplayGroup('extra'); $extra->setDecorators(array('FormElements', 'Fieldset', array('HtmlTag', array('tag' => 'fieldset', 'class' => 'well the-fieldset')))); $this->addDisplayGroup(array('Save', 'Reset'), 'submit', array('disableLoadDefaultDecorators' => false, 'legend' => 'Thông tin học vấn')); $submit = $this->getDisplayGroup('submit'); $submit->setDecorators(array('FormElements', 'Fieldset', array('HtmlTag', array('tag' => 'fieldset', 'class' => 'well the-fieldset')))); }
'; }); $this->attach('view_body', 20, function ($view) { echo '<script type="text/javascript" src="' . $view->baseUrl() . '/addons/' . basename(__DIR__) . '/jquery.autosize.min.js"></script>'; echo ' <script type="text/javascript"> // attach to postLoaded $(document).on("postsLoaded", function (e) { $(".add-comment textarea#comment").trigger("autosize.destroy").autosize({append:""}); }); // focus $(document).on("click", ".add-comment-btn", function (e) { $(this).closest(".single-post").find(".add-comment textarea#comment").focus(); }); </script> '; }); // Override default AddComent Form $this->attach('form_AddComment', 10, function (&$form) { $translator = Zend_Registry::get('Zend_Translate'); // remove input element $form->removeElement('comment'); // add new textarea element $comment = new Zend_Form_Element_Textarea('comment'); $comment->setDecorators(array('ViewHelper', 'Errors'))->addFilter('StripTags')->setRequired(true)->setAttrib('autocomplete', 'off')->setAttrib('class', 'form-control')->setAttrib('cols', '40')->setAttrib('rows', '1')->setAttrib('placeholder', $translator->translate('Write a comment...')); $form->addElement($comment); return; });