public function testFormElementHelperIntegration()
    {
        $element = new \Zend\Form\Element\Select('test');
        $element->setAttribute('type', 'select_untranslated')->setValueOptions(array('Yes<b>', 'No'));
        $expected = <<<EOT
<select name="test"><option value="0">Yes&lt;b&gt;</option>
<option value="1">No</option></select>
EOT;
        $view = new \Zend\View\Renderer\PhpRenderer();
        $view->setHelperPluginManager(static::$_helperManager);
        $helper = static::$_helperManager->get('formElement');
        $helper->setView($view);
        $this->assertEquals($expected, $helper($element));
    }
Example #2
0
 /**
  * @param \Secretary\Entity\User $user
  * @param string                 $action
  */
 public function __construct(\Secretary\Entity\User $user, $action = '#')
 {
     parent::__construct('userForm');
     $this->setAttribute('method', 'post')->setAttribute('action', $action)->setAttribute('class', 'form-horizontal');
     $displayName = new \Zend\Form\Element\Text('display_name');
     $displayName->setAttribute('required', 'required')->setAttribute('label', 'Display Name')->setValue($user->getDisplayName());
     $this->add($displayName);
     $select = new \Zend\Form\Element\Select('language');
     $select->setAttribute('required', 'required')->setAttribute('label', 'Select Language')->setValueOptions(array('de_DE' => 'german', 'en_US' => 'english'))->setValue($user->getLanguage());
     $this->add($select);
     $notifications = new \Zend\Form\Element\Select('notifications');
     $notifications->setAttribute('required', 'required')->setAttribute('label', 'Enable notifications')->setValueOptions(array('0' => 'no', '1' => 'yes'))->setValue($user->getNotifications());
     $this->add($notifications);
     $submit = new \Zend\Form\Element\Submit('submit');
     $submit->setAttribute('class', 'btn btn-primary')->setAttribute('value', 'save');
     $this->add($submit);
 }
Example #3
0
 /**
  * Rendering filters
  *
  * @return string
  */
 public function renderFilters()
 {
     $headers = $this->getTable()->getHeaders();
     $render = '';
     foreach ($headers as $name => $params) {
         if (isset($params['filters'])) {
             $value = $this->getTable()->getParamAdapter()->getValueOfFilter($name);
             $id = 'zff_' . $name;
             if (is_string($params['filters'])) {
                 $element = new \Zend\Form\Element\Text($id);
             } else {
                 $element = new \Zend\Form\Element\Select($id);
                 $element->setValueOptions($params['filters']);
             }
             $element->setAttribute('class', 'filter form-control');
             $element->setValue($value);
             $render .= sprintf('<td>%s</td>', $this->getRenderer()->formRow($element));
         } else {
             $render .= '<td></td>';
         }
     }
     return sprintf('<tr>%s</tr>', $render);
 }
Example #4
0
 /**
  * Rendering filters
  *
  * @return string
  */
 public function renderFiltersInHeader()
 {
     $headers = $this->getTable()->getHeaders();
     $render = '';
     foreach ($headers as $name => $params) {
         if (isset($params['filters'])) {
             $value = $this->getTable()->getParamAdapter()->getValueOfFilter($name);
             $id = 'zff_' . $name;
             if (!isset($params['placeholder'])) {
                 $params['placeholder'] = $params['title'];
             }
             if (!is_array($params['filters']) && class_exists($params['filters'])) {
                 $element = new $params['filters']($id);
             } else {
                 if (is_string($params['filters'])) {
                     $element = new \Zend\Form\Element\Text($id);
                 } else {
                     $element = new \Zend\Form\Element\Select($id);
                     $element->setValueOptions($params['filters']);
                 }
             }
             $element->setAttribute('class', 'filter form-control input-sm');
             $element->setAttribute('placeholder', $params['placeholder']);
             $element->setAttribute('data-placeholder', $params['placeholder']);
             $element->setValue($value);
             $render .= sprintf('<div class="form-group">%s</div>', $this->getRenderer()->formRow($element));
         } else {
             //                $render .= '<div></div>';
         }
     }
     return sprintf('<div class="form-body">%s</div>', $render);
 }
Example #5
0
 /**
  * Rendering filters
  *
  * @return string
  */
 public function renderFilters()
 {
     $headers = $this->getTable()->getHeaders();
     $render = '';
     $options = $this->getTable()->getOptions();
     $tableName = strtolower($options->getName());
     $session = new Container();
     foreach ($headers as $name => $params) {
         if (isset($params['filters'])) {
             $value = $this->getTable()->getParamAdapter()->getValueOfFilter($name);
             $id = 'zff_' . $tableName . '_' . $name;
             if (is_string($params['filters'])) {
                 $element = new \Zend\Form\Element\Text($id);
                 $element->setAttribute('placeholder', 'Pesquisar ' . strtolower($params['title']));
             } else {
                 $element = new \Zend\Form\Element\Select($id);
                 $element->setValueOptions($params['filters']);
             }
             $class = '';
             if (isset($params['filter_class'])) {
                 $class = trim($params['filter_class']);
             }
             $element->setAttribute('class', 'filter form-control ' . $class);
             // $value = $session->offsetGet($id);
             $element->setValue($value);
             $session->offsetSet($id, $value);
             $render .= sprintf('<td>%s</td>', $this->getRenderer()->formRow($element));
         } else {
             $render .= '<td></td>';
         }
     }
     return sprintf('<tfoot><tr>%s</tr><tfoot>', $render);
 }