Exemplo n.º 1
0
 /**
  * Renders the element widget
  *
  * @param array attributes
  * @return string
  */
 public function render($attributes = null)
 {
     /**
      * Merged passed attributes with previously defined ones
      */
     return \WpPepVN\Tag::submitButton($this->prepareAttributes($attributes));
 }
Exemplo n.º 2
0
 public function init(DependencyInjection $di)
 {
     $this->di = $di;
     $this->_dependencyInjector = $this->di;
     $this->setDI($this->di);
     Tag::setDI($this->di);
     $this->view = $this->di->getShared('view');
     //$this->view->adminNotice = $this->di->getShared('adminNotice');
     $this->view->translate = $this->di->getShared('translate');
     $this->request = $this->di->getShared('request');
 }
Exemplo n.º 3
0
 /**
  * Renders the element widget returning html
  *
  * @param array attributes
  * @return string
  */
 public function render($attributes = null)
 {
     return \WpPepVN\Tag::checkField($this->prepareAttributes($attributes, true));
 }
Exemplo n.º 4
0
 /**
  * Renders the element widget returning html
  *
  * @param array $attributes
  * @return string
  */
 public function render($attributes = null)
 {
     return \WpPepVN\Tag::numericField($this->prepareAttributes($attributes));
 }
Exemplo n.º 5
0
 /**
  * Renders the element widget
  *
  * @param array attributes
  * @return string
  */
 public function render($attributes = null)
 {
     return Tag::textArea($this->prepareAttributes($attributes));
 }
Exemplo n.º 6
0
 /**
  * Generates a SELECT tag
  *
  * @param array parameters
  * @param array data
  */
 public static function selectField($parameters, $data = null)
 {
     if (!is_array($parameters)) {
         $params = array($parameters, $data);
     } else {
         $params = $parameters;
     }
     $id = null;
     if (isset($params[0])) {
         $id = $params[0];
     } else {
         if (isset($params['id'])) {
             $params[0] = $params['id'];
             $id = $params[0];
         }
     }
     /**
      * Automatically assign the id if the name is not an array
      */
     if (false === strpos($id, '[')) {
         if (!isset($params['id'])) {
             $params['id'] = $id;
         }
     }
     if (!isset($params['name'])) {
         $params['name'] = $id;
     } else {
         $name = $params['name'];
         if (!$name) {
             $params['name'] = $id;
         }
     }
     if (!isset($params['value'])) {
         $value = BaseTag::getValue($id, $params);
     } else {
         $value = $params['value'];
         unset($params['value']);
     }
     if (isset($params['useEmpty'])) {
         $useEmpty = $params['useEmpty'];
         if (!isset($params['emptyValue'])) {
             $emptyValue = '';
         } else {
             $emptyValue = $params['emptyValue'];
             unset($params['emptyValue']);
         }
         if (!isset($params['emptyText'])) {
             $emptyText = 'Choose...';
         } else {
             $emptyText = $params['emptyText'];
             unset($params['emptyText']);
         }
         unset($params['useEmpty']);
     }
     if (!isset($params[1])) {
         $options = $data;
     } else {
         $options = $params[1];
     }
     if (is_object($options)) {
         /**
          * The options is a resultset
          */
         if (!isset($params['using'])) {
             throw new Exception('The \'using\' parameter is required');
         } else {
             $using = $params['using'];
             if (!is_array($using) && !is_object($using)) {
                 throw new Exception('The \'using\' parameter should be an array');
             }
         }
     }
     unset($params['using']);
     $code = BaseTag::renderAttributes('<select', $params) . '>' . PHP_EOL;
     if ($useEmpty) {
         /**
          * Create an empty value
          */
         $code .= '<option value="' . $emptyValue . '">' . $emptyText . '</option>' . PHP_EOL;
     }
     if (is_object($options)) {
         /**
          * Create the SELECT's option from a resultset
          */
         $code .= self::_optionsFromResultset($options, $using, $value, '</option>' . PHP_EOL);
     } else {
         if (is_array($options)) {
             /**
              * Create the SELECT's option from an array
              */
             $code .= self::_optionsFromArray($options, $value, '</option>' . PHP_EOL);
         } else {
             throw new Exception('Invalid data provided to SELECT helper');
         }
     }
     $code .= '</select>';
     return $code;
 }
Exemplo n.º 7
0
 /**
  * Clears every element in the form to its default value
  */
 public function clear()
 {
     Tag::setDefault($this->_name, null);
     return $this;
 }