Example #1
0
 /**
  * Builds a HTML SELECT tag using a \Phalcon\Mvc\Model resultset as options
  *
  *<code>
  *  echo \Phalcon\Tag::select(array(
  *      "robotId",
  *      Robots::find("type = 'mechanical'"),
  *      "using" => array("id", "name")
  *  ));
  *</code>
  *
  * Volt syntax:
  *<code>
  * {{ select("robotId", robots, "using": ["id", "name"]) }}
  *</code>
  *
  * @param array $parameters
  * @param null|array $data
  * @return string
  * @throws TagException
  */
 public static function select($parameters, $data = null)
 {
     if (is_null($data) === true) {
         $data = array();
     } elseif (is_array($data) === false) {
         //@note added type-check
         throw new TagException('Invalid parameter type.');
     }
     return Select::selectField($parameters, $data);
 }
Example #2
0
 /**
  * Renders the element widget returning html
  *
  * @param array|null $attributes
  * @return string
  * @throws Exception
  */
 public function render($attributes = null)
 {
     if (is_array($attributes) === false && is_null($attributes) === false) {
         throw new Exception('Invalid parameter type.');
     }
     //Merge passed attributes with previously defined ones
     return TagSelect::selectField($this->prepareAttributes($attributes), $this->_optionsValues);
 }