Пример #1
0
 public function init()
 {
     $this->setMethod("post");
     $title = new Zend_Form_Element_Text("title");
     $title->setAttrib("placeholder", "Title");
     $title->setAttrib("class", "form-control");
     $title->setLabel("Title: ");
     $title->setRequired();
     $body = new Zend_Form_Element_Textarea("body");
     $body->setAttrib("class", "form-control");
     $body->setAttrib("placeholder", "Write body here....");
     $body->setLabel("Body: ");
     $body->setAttrib("rows", "5");
     $body->setAttrib("cols", "55");
     $body->setRequired();
     $picture = new Zend_Form_Element_File('picture');
     $picture->setLabel("Picture:");
     $picture->setRequired();
     $picture->setDestination('/var/www/html/RNR/public/images/thread');
     $stick = new Zend_Form_Element_Radio("stick");
     $stick->setLabel("Sticky:");
     $stick->addMultiOption("on", "on");
     $stick->addMultiOption("off", "off");
     $stick->setRequired();
     $id = new Zend_Form_Element_Hidden("id");
     $submit = new Zend_Form_Element_Submit("Submit");
     $submit->setAttrib("class", "btn btn-primary");
     $submit->setLabel("Save");
     $rest = new Zend_Form_Element_Submit('Rest');
     $rest->setAttrib("class", "btn btn-info");
     $this->addElements(array($id, $title, $body, $picture, $stick, $submit, $rest));
 }
Пример #2
0
 /**
  * Set form elements for a Content_Node object
  *
  * @param Content_Node $target
  * @param string $action
  * @param array $options
  */
 function __construct(Content_Node $target, $action, $options = array())
 {
     parent::__construct($options);
     $this->setAction($action)->setMethod('post');
     $this->setAttrib('id', 'content_form');
     $type = Zoo::getService('content')->getType($target->type);
     try {
         Zoo::getService("hook")->trigger("Node", "Form", $this, $target);
     } catch (Zoo_Exception_Service $e) {
         // Hook service not available - log? Better not, some people may live happily without a hook service
     }
     if ($type->has_publishdate_select) {
         // Add publish date and approval settings
         $status = new Zend_Form_Element_Radio('status', array('class' => 'content_status'));
         $status->setLabel('Status');
         $status->addMultiOption(0, Zoo::_('Unpublished'));
         $status->addMultiOption(1, Zoo::_('Published'));
         //$status->addMultiOption(2, Zoo::_('Ready for review'));
         $publishdate = new ZendX_JQuery_Form_Element_DatePicker('published');
         $publishdate->setLabel('Publish date');
         $this->addElements(array($status, $publishdate));
         $this->addDisplayGroup(array('status', 'published'), 'content_publish', array('legend' => Zoo::_("Publish settings")));
         //Workaround for JQuery Theme
         /**
          * @todo replace with unified jquery UI theme selector
          */
         $view = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer')->view;
         $view->headLink()->appendStylesheet('http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/smoothness/jquery-ui.css');
     }
     $submit = new Zend_Form_Element_Submit('save');
     $submit->setLabel('Save');
     $this->addElement($submit);
     if ($target->id > 0) {
         $id_ele = new Zend_Form_Element_Hidden('id');
         $id_ele->setValue(intval($target->id));
         $this->addElement($id_ele);
     } else {
         $target->status = 0;
     }
     $this->addElement(new Zend_Form_Element_Hidden('type', array('value' => $target->type)));
     $this->addElement(new Zend_Form_Element_Hidden('pid', array('value' => $target->pid)));
     $populate = $target->toArray();
     $populate['published'] = date("d M y", $target->published ? $target->published : time());
     $this->populate($populate);
 }
Пример #3
0
 public function init()
 {
     $immobile = new Zend_Form_Element_Radio('immobile');
     $immobile->addMultiOption('Affitto', 'Affitto')->addMultiOption('Vendita', 'Vendita')->setLabel('Immobile in ')->setRequired(true)->removeDecorator('Errors')->addErrorMessage('Specificare il tipo di Immobile');
     $this->addElement($immobile);
     $tipi = array('0' => '- Seleziona un Tipo - ', 'Ufficio' => 'Ufficio', 'Appartamento' => 'Appartamento', 'Attico' => 'Attico', 'Attivita\' Commerciale e/o Negozi' => 'Attivita\' Commerciale e/o Negozi', 'Garage e/o Box' => 'Garage e/o Box', 'Ville e Villini' => 'Ville e Villini', 'Casali e/o Antico' => 'Casali e/o Antico', 'Lotti Edificabili' => 'Lotti Edificabili', 'Casa Vacanza' => 'Casa Vacanza', 'Terreni' => 'Terreni');
     $tipo = new Zend_Form_Element_Select('tipo');
     $tipo->setLabel('Tipologia')->addMultiOptions($tipi);
     $this->addElement($tipo);
     $stati = array('0' => '- Seleziona Stato -', 'Arredato' => 'Arredato', 'Non Arredato' => 'Non Arredato');
     $stato = new Zend_Form_Element_Select('stato');
     $stato->setLabel('Stato')->addMultiOptions($stati);
     $this->addElement($stato);
     $this->addElement('submit', 'submit', array('label' => 'Inizia Ricerca'));
     $this->setAction('/search/search');
 }
Пример #4
0
 /**
  * Faz o parse de um elemento <radio> para Zend_Form.
  * @param SimpleXMLElement $element
  */
 protected function parseRadio($element)
 {
     $form_element = new Zend_Form_Element_Radio((string) $element->id);
     $form_element->setSeparator("");
     $form_element->setLabel((string) $element->label);
     foreach ($element->option as $option) {
         $form_element->addMultiOption((string) $option->value, $option->label);
     }
     if (isset($element->value)) {
         $form_element->setValue($element->value);
     } else {
         if (isset($element->default)) {
             $form_element->setValue($element->default);
         }
     }
     return $form_element;
 }
Пример #5
0
 public function __construct($options = null)
 {
     Zend_Dojo::enableForm($this);
     parent::__construct();
     $cust = new settings_Model_Customization();
     $sample = $cust->fetchcustomized();
     foreach ($sample as $cust1) {
         switch ($cust1['feild_type']) {
             case "text":
                 $Instance = new Zend_Form_Element_Text($cust1['feild_name']);
                 $Instance->setLabel($cust1['display_name']);
                 $Instance->setAttrib('size', '8');
                 if ($cust1['feild_name']) {
                     $Instance->setRequired(true)->setDecorators(array('ViewHelper', array('Description', array('tag' => '', 'escape' => false)), 'Errors', array(array('data' => 'HtmlTag'), array('tag' => 'td')), array('Label', array('tag' => 'td', 'requiredSuffix' => ' *')), array(array('row' => 'HtmlTag'), array('tag' => 'tr'))));
                 }
                 break;
             case "radio":
                 $Instance = new Zend_Form_Element_Radio($cust1['feild_name']);
                 $Instance->setLabel($cust1['display_name']);
                 $appliesTo = $cust->getTableInfo($cust1['table_name']);
                 foreach ($appliesTo as $appliesTo1) {
                     foreach ($appliesTo as $key => $value) {
                         $i = 1;
                         foreach ($value as $key1 => $value1) {
                             if ($i % 2 == 0) {
                                 //faltu start
                                 $f2 = $appliesTo1[$key1];
                             } else {
                                 $f1 = $appliesTo1[$key1];
                             }
                             $Instance->addMultiOption($f1, $f2);
                             $i++;
                         }
                         //faltu end
                     }
                 }
                 if ($cust1['feild_name']) {
                     $Instance->setRequired(true)->addValidators(array(array('NotEmpty')))->setDecorators(array('ViewHelper', array('Description', array('tag' => '', 'escape' => false)), 'Errors', array(array('data' => 'HtmlTag'), array('tag' => 'td')), array('Label', array('tag' => 'td', 'requiredSuffix' => ' *')), array(array('row' => 'HtmlTag'), array('tag' => 'tr'))));
                 }
                 break;
             case "select":
                 $Instance = new Zend_Form_Element_Select($cust1['feild_name']);
                 $Instance->setLabel($cust1['display_name']);
                 $appliesTo = $cust->getTableInfo($cust1['table_name']);
                 foreach ($appliesTo as $appliesTo1) {
                     foreach ($appliesTo as $key => $value) {
                         $i = 1;
                         foreach ($value as $key1 => $value1) {
                             if ($i % 2 == 0) {
                                 //faltu start
                                 $f2 = $appliesTo1[$key1];
                             } else {
                                 $f1 = $appliesTo1[$key1];
                             }
                             $Instance->addMultiOption($f1, $f2);
                             $i++;
                         }
                         //faltu end
                     }
                 }
                 if ($cust1['feild_name']) {
                     $Instance->setRequired(true)->addValidators(array(array('NotEmpty')))->setDecorators(array('ViewHelper', array('Description', array('tag' => '', 'escape' => false)), 'Errors', array(array('data' => 'HtmlTag'), array('tag' => 'td')), array('Label', array('tag' => 'td', 'requiredSuffix' => ' *')), array(array('row' => 'HtmlTag'), array('tag' => 'tr'))));
                 }
                 break;
             case "description":
                 $Instance = new Zend_Form_Element_Textarea($cust1['feild_name'], array('rows' => 3, 'cols' => 20));
                 $Instance->setLabel($cust1['display_name']);
                 if ($cust1['feild_name']) {
                     $Instance->setRequired(true)->addValidators(array(array('NotEmpty')))->setDecorators(array('ViewHelper', array('Description', array('tag' => '', 'escape' => false)), 'Errors', array(array('data' => 'HtmlTag'), array('tag' => 'td')), array('Label', array('tag' => 'td', 'requiredSuffix' => ' *')), array(array('row' => 'HtmlTag'), array('tag' => 'tr'))));
                 }
                 break;
             case "checkbox":
                 $Instance = new Zend_Form_Element_MultiCheckbox($cust1['feild_name']);
                 $Instance->setLabel($cust1['display_name']);
                 $appliesTo = $cust->getTableInfo($cust1['table_name']);
                 foreach ($appliesTo as $appliesTo1) {
                     foreach ($appliesTo as $key => $value) {
                         $i = 1;
                         foreach ($value as $key1 => $value1) {
                             if ($i % 2 == 0) {
                                 //faltu starta
                                 $f2 = $appliesTo1[$key1];
                             } else {
                                 $f1 = $appliesTo1[$key1];
                             }
                             $Instance->addMultiOption($f1, $f2);
                             $i++;
                         }
                         //faltu end
                     }
                 }
                 if ($cust1['feild_name']) {
                     $Instance->setRequired(true)->addValidators(array(array('NotEmpty')))->setDecorators(array('ViewHelper', array('Description', array('tag' => '', 'escape' => false)), 'Errors', array(array('data' => 'HtmlTag'), array('tag' => 'td')), array('Label', array('tag' => 'td', 'requiredSuffix' => ' *')), array(array('row' => 'HtmlTag'), array('tag' => 'tr'))));
                 }
                 break;
         }
         $this->addElements(array($Instance));
     }
 }
Пример #6
0
 /**
  * 以<radio>标签的形式输出
  * 
  * @param ZtChart_Model_DbTable_Role_Rowset $rowset
  * @param array $attributes
  */
 protected function _htmlRadio(ZtChart_Model_DbTable_Role_Rowset $rowset, $attributes = array())
 {
     if (isset($attributes['options'])) {
         $options = $attributes['options'];
         unset($attributes['options']);
     } else {
         $options = array();
     }
     $htmlRadio = new Zend_Form_Element_Radio(array_merge($this->_attributes['radio'], $attributes));
     $htmlRadio->clearDecorators()->addDecorator('ViewHelper');
     $htmlRadio->addMultiOptions($options);
     foreach ($rowset as $row) {
         $htmlRadio->addMultiOption($row->role_id, $row->role_name);
     }
     return $htmlRadio;
 }