Beispiel #1
0
 function __invoke($name, $value, $label, array $attributes = null)
 {
     $attributes = $this->setDefaultAttributes($attributes);
     $element = new Button($name);
     $element->setValue($value)->setAttributes($attributes)->setLabel($label);
     return $this->render($element);
 }
 public function init()
 {
     $fileupload = new Element\File('files');
     $fileupload->setLabel("files");
     $fileupload->setAttribute('multiple', 'multiple');
     $this->add($fileupload);
     $button = new Element\Button('start');
     $button->setAttribute("type", 'submit');
     $button->setValue("Start upload")->setLabel("Start upload");
     $this->add($button);
     $button = new Element\Button('cancel');
     $button->setAttribute("type", 'reset');
     $button->setValue("Cancel upload")->setLabel("Cancel upload");
     $this->add($button);
     $button = new Element\Button('delete');
     $button->setAttribute("type", 'button');
     $button->setValue("Delete")->setLabel("Delete");
     $this->add($button);
     $checkbox = new Element\Checkbox('toggle');
     $checkbox->setValue("Toggle")->setLabel("Toggle");
     $checkbox->setAttribute("required", "");
     $this->add($checkbox);
 }
 public function setValue($value)
 {
     return parent::setValue(\Zend\Json\Json::encode($value));
 }
Beispiel #4
0
 /**
  * Função que prepara os botões do formulário
  * @param  type                      $buttonName
  * @param  array                     $params
  * @return \Zend\Form\Element\Button
  */
 private function prepareButtons($buttonName, array $params = array())
 {
     /* Preparação dos botões */
     $class = "btn ";
     $this->aOptions = array();
     if (strtolower($params['type']) == 'submit') {
         //$element = new ZendFormElement\Submit($buttonName);
         $element = new ZendFormElement\Button($buttonName);
         $this->aAttributes['type'] = 'submit';
         //$class .= ' btn-success ';
     } elseif (strtolower($params['type']) == 'button') {
         $element = new ZendFormElement\Button($buttonName);
         //$class .= ' btn_default ';
     }
     if (isset($params['class']) and !empty($params['class'])) {
         $this->aAttributes['class'] = $class . $params['class'];
     }
     $this->aOptions['column-size'] = 'sm-6 col-sm-offset-2';
     $this->aOptions['twb-layout'] = 'inline';
     $element->setValue($this->getTranslator('btn_' . $buttonName));
     $element->setLabel($this->getTranslator('btn_' . $buttonName));
     $element->setAttributes($this->aAttributes);
     $element->setOptions($this->aOptions);
     return $element;
 }