当前位置: 首页>>代码示例>>PHP>>正文


PHP Tag::selectStatic方法代码示例

本文整理汇总了PHP中Phalcon\Tag::selectStatic方法的典型用法代码示例。如果您正苦于以下问题:PHP Tag::selectStatic方法的具体用法?PHP Tag::selectStatic怎么用?PHP Tag::selectStatic使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Phalcon\Tag的用法示例。


在下文中一共展示了Tag::selectStatic方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testSelect

    public function testSelect()
    {
        $data = array("status", array("Active" => array('A1' => 'A One', 'A2' => 'A Two'), "B" => "B One"));
        $html = <<<HTML
<select id="status" name="status">
\t<optgroup label="Active">
\t<option value="A1">A One</option>
\t<option value="A2">A Two</option>
\t</optgroup>
\t<option value="B">B One</option>
</select>
HTML;
        $di = new Phalcon\DI\FactoryDefault();
        Tag::setDI($di);
        $ret = Tag::selectStatic($data);
        $this->assertEquals($ret, $html);
        $html = <<<HTML
<select id="status" name="status">
\t<optgroup label="Active">
\t<option selected="selected" value="A1">A One</option>
\t<option value="A2">A Two</option>
\t</optgroup>
\t<option value="B">B One</option>
</select>
HTML;
        Tag::setDefault("status", "A1");
        $ret = Tag::selectStatic($data);
        $this->assertEquals($ret, $html);
    }
开发者ID:UqiOnline,项目名称:cphalcon7,代码行数:29,代码来源:TagTest.php

示例2: registryFunctions

 /**
  * Registers common function in Twig
  *
  * @param \Phalcon\Mvc\ViewInterface $view
  * @param \Phalcon\DiInterface       $di
  * @param array                      $userFunctions
  */
 protected function registryFunctions($view, DiInterface $di, $userFunctions = array())
 {
     $options = array('is_safe' => array('html'));
     $functions = array(new \Twig_SimpleFunction('content', function () use($view) {
         return $view->getContent();
     }, $options), new \Twig_SimpleFunction('partial', function ($partialPath) use($view) {
         return $view->partial($partialPath);
     }, $options), new \Twig_SimpleFunction('linkTo', function ($parameters, $text = null) {
         return \Phalcon\Tag::linkTo($parameters, $text);
     }, $options), new \Twig_SimpleFunction('textField', function ($parameters) {
         return \Phalcon\Tag::textField($parameters);
     }, $options), new \Twig_SimpleFunction('passwordField', function ($parameters) {
         return \Phalcon\Tag::passwordField($parameters);
     }, $options), new \Twig_SimpleFunction('hiddenField', function ($parameters) {
         return \Phalcon\Tag::hiddenField($parameters);
     }, $options), new \Twig_SimpleFunction('fileField', function ($parameters) {
         return \Phalcon\Tag::fileField($parameters);
     }, $options), new \Twig_SimpleFunction('checkField', function ($parameters) {
         return \Phalcon\Tag::checkField($parameters);
     }, $options), new \Twig_SimpleFunction('radioField', function ($parameters) {
         return \Phalcon\Tag::radioField($parameters);
     }, $options), new \Twig_SimpleFunction('submitButton', function ($parameters) {
         return \Phalcon\Tag::submitButton($parameters);
     }, $options), new \Twig_SimpleFunction('selectStatic', function ($parameters, $data = array()) {
         return \Phalcon\Tag::selectStatic($parameters, $data);
     }, $options), new \Twig_SimpleFunction('select', function ($parameters, $data = array()) {
         return \Phalcon\Tag::select($parameters, $data);
     }, $options), new \Twig_SimpleFunction('textArea', function ($parameters) {
         return \Phalcon\Tag::textArea($parameters);
     }, $options), new \Twig_SimpleFunction('form', function ($parameters = array()) {
         return \Phalcon\Tag::form($parameters);
     }, $options), new \Twig_SimpleFunction('endForm', function () {
         return \Phalcon\Tag::endForm();
     }, $options), new \Twig_SimpleFunction('getTitle', function () {
         return \Phalcon\Tag::getTitle();
     }, $options), new \Twig_SimpleFunction('stylesheetLink', function ($parameters = null, $local = true) {
         return \Phalcon\Tag::stylesheetLink($parameters, $local);
     }, $options), new \Twig_SimpleFunction('javascriptInclude', function ($parameters = null, $local = true) {
         return \Phalcon\Tag::javascriptInclude($parameters, $local);
     }, $options), new \Twig_SimpleFunction('image', function ($parameters) {
         return \Phalcon\Tag::image($parameters);
     }, $options), new \Twig_SimpleFunction('friendlyTitle', function ($text, $separator = null, $lowercase = true) {
         return \Phalcon\Tag::friendlyTitle($text, $separator, $lowercase);
     }, $options), new \Twig_SimpleFunction('getDocType', function () {
         return \Phalcon\Tag::getDocType();
     }, $options), new \Twig_SimpleFunction('getSecurityToken', function () use($di) {
         return $di->get("security")->getToken();
     }, $options), new \Twig_SimpleFunction('getSecurityTokenKey', function () use($di) {
         return $di->get("security")->getTokenKey();
     }, $options), new \Twig_SimpleFunction('url', function ($route) use($di) {
         return $di->get("url")->get($route);
     }, $options));
     if (!empty($userFunctions)) {
         $functions = array_merge($functions, $userFunctions);
     }
     foreach ($functions as $function) {
         $this->twig->addFunction($function);
     }
 }
开发者ID:lisong,项目名称:incubator,代码行数:66,代码来源:Twig.php

示例3: registryFunctions

 /**
  * Registers common function in Twig
  *
  * @param \Phalcon\Mvc\ViewInterface $view
  */
 private function registryFunctions($view)
 {
     $options = array('is_safe' => array('html'));
     $functions = array(new \Twig_SimpleFunction('content', function () use($view) {
         return $view->getContent();
     }, $options), new \Twig_SimpleFunction('partial', function ($partialPath) use($view) {
         return $view->partial($partialPath);
     }, $options), new \Twig_SimpleFunction('linkTo', function ($parameters, $text = null) {
         return \Phalcon\Tag::linkTo($parameters, $text);
     }, $options), new \Twig_SimpleFunction('textField', function ($parameters) {
         return \Phalcon\Tag::textField($parameters);
     }, $options), new \Twig_SimpleFunction('passwordField', function ($parameters) {
         return \Phalcon\Tag::passwordField($parameters);
     }, $options), new \Twig_SimpleFunction('hiddenField', function ($parameters) {
         return \Phalcon\Tag::hiddenField($parameters);
     }, $options), new \Twig_SimpleFunction('fileField', function ($parameters) {
         return \Phalcon\Tag::fileField($parameters);
     }, $options), new \Twig_SimpleFunction('checkField', function ($parameters) {
         return \Phalcon\Tag::checkField($parameters);
     }, $options), new \Twig_SimpleFunction('radioField', function ($parameters) {
         return \Phalcon\Tag::radioField($parameters);
     }, $options), new \Twig_SimpleFunction('submitButton', function ($parameters) {
         return \Phalcon\Tag::submitButton($parameters);
     }, $options), new \Twig_SimpleFunction('selectStatic', function ($parameters, $data = []) {
         return \Phalcon\Tag::selectStatic($parameters, $data);
     }, $options), new \Twig_SimpleFunction('select', function ($parameters, $data = []) {
         return \Phalcon\Tag::select($parameters, $data);
     }, $options), new \Twig_SimpleFunction('textArea', function ($parameters) {
         return \Phalcon\Tag::textArea($parameters);
     }, $options), new \Twig_SimpleFunction('form', function ($parameters = []) {
         return \Phalcon\Tag::form($parameters);
     }, $options), new \Twig_SimpleFunction('endForm', function () {
         return \Phalcon\Tag::endForm();
     }, $options), new \Twig_SimpleFunction('getTitle', function () {
         return \Phalcon\Tag::getTitle();
     }, $options), new \Twig_SimpleFunction('getTitle', function () {
         return \Phalcon\Tag::getTitle();
     }, $options), new \Twig_SimpleFunction('stylesheetLink', function ($parameters = null, $local = true) {
         return \Phalcon\Tag::stylesheetLink($parameters, $local);
     }, $options), new \Twig_SimpleFunction('javascriptInclude', function ($parameters = null, $local = true) {
         return \Phalcon\Tag::javascriptInclude($parameters, $local);
     }, $options), new \Twig_SimpleFunction('image', function ($parameters) {
         return \Phalcon\Tag::image($parameters);
     }, $options), new \Twig_SimpleFunction('friendlyTitle', function ($text, $separator = null, $lowercase = true) {
         return \Phalcon\Tag::friendlyTitle($text, $separator, $lowercase);
     }, $options), new \Twig_SimpleFunction('getDocType', function () {
         return \Phalcon\Tag::getDocType();
     }, $options));
     foreach ($functions as $function) {
         $this->_twig->addFunction($function);
     }
 }
开发者ID:tashik,项目名称:phalcon_core,代码行数:57,代码来源:Twig.php

示例4: render

 /**
  * @TODO array merge with attr
  * Custom DateTime Selector
  * @param null $attr
  * @return string
  */
 public function render($attr = null)
 {
     $years = [date('Y') => date('Y'), date('Y') + 1 => date('Y') + 1];
     $months = [1 => "Jan", 2 => "Feb", 3 => "Mar", 4 => "Apr", 5 => "May", 6 => "Jun", 7 => "Jul", 8 => "Aug", 9 => "Sep", 10 => "Oct", 11 => "Nov", 12 => "Dec"];
     $days = array_combine(range(1, 31), range(1, 31));
     $hours = array_combine(range(0, 23), range(0, 23));
     $mins = ['00' => 0, '05' => 5, 10 => 10, 15 => 15, 20 => 20, 25 => 25, 30 => 30, 35 => 35, 40 => 40, 45 => 45, 50 => 50, 55 => 55];
     $val = $this->getValue();
     $html = \Phalcon\Tag::selectStatic([$this->getName() . '[year]', $years, 'value' => $val['year'], 'useEmpty' => true, 'emptyText' => 'Year', 'class' => $this->getName(), 'style' => 'min-width: auto']);
     $html .= '.' . \Phalcon\Tag::selectStatic([$this->getName() . '[month]', $months, 'value' => $val['month'], 'useEmpty' => true, 'emptyText' => 'Month', 'class' => $this->getName(), 'style' => 'min-width: auto']);
     $html .= '.' . \Phalcon\Tag::selectStatic([$this->getName() . '[day]', $days, 'value' => $val['day'], 'useEmpty' => true, 'emptyText' => 'Day', 'class' => $this->getName(), 'style' => 'min-width: auto']);
     $html .= ' &nbsp; ' . \Phalcon\Tag::selectStatic([$this->getName() . '[hour]', $hours, 'value' => $val['hour'], 'useEmpty' => true, 'emptyText' => 'Hour', 'class' => $this->getName(), 'style' => 'min-width: auto']);
     $html .= ':' . \Phalcon\Tag::selectStatic([$this->getName() . '[min]', $mins, 'value' => $val['min'], 'useEmpty' => true, 'emptyText' => 'Min.', 'class' => $this->getName(), 'style' => 'min-width: auto']);
     return $html;
 }
开发者ID:mpetcu,项目名称:lime-juice,代码行数:21,代码来源:DateTimeSelector.php

示例5: selectStatic

 public static function selectStatic($parameters, $data = null)
 {
     return parent::selectStatic($parameters, $data);
 }
开发者ID:mattvb91,项目名称:cphalcon,代码行数:4,代码来源:Tag.php

示例6: testSelectStaticDisplayToElementNotPresentXHTML

 /**
  * Tests selectStatic with setDefault to an non existent element
  *
  * @author Nikos Dimopoulos <nikos@phalconphp.com>
  * @since  2012-10-26
  */
 public function testSelectStaticDisplayToElementNotPresentXHTML()
 {
     $params = array('some_field_name', 'class' => 'some_class', 'size' => '10');
     \Phalcon\Tag::displayTo('some_field', 'I');
     $options = array('A' => 'Active', 'I' => 'Inactive');
     $expected = '<select id="some_field_name" name="some_field_name" class="some_class" size="10">' . PHP_EOL . chr(9) . '<option value="A">Active</option>' . PHP_EOL . chr(9) . '<option value="I">Inactive</option>' . PHP_EOL . '</select>';
     $actual = \Phalcon\Tag::selectStatic($params, $options);
     \Phalcon\Tag::displayTo('some_field', '');
     $this->assertEquals($expected, $actual, sprintf($this->message, 'XHTML selectStatic with setDefault'));
 }
开发者ID:lisong,项目名称:cphalcon,代码行数:16,代码来源:UnitTest.php

示例7: array

<?php

echo \Phalcon\Tag::selectStatic(array("color", array("Yellow" => "Yellow", "Blue" => "Blue", "Red" => "Red")));
开发者ID:aodkrisda,项目名称:phalcon-code,代码行数:3,代码来源:tags-356.php

示例8: selectStatic

 /**
  * Create static select with bootstrap style
  * @param string|array $params The attribute or an array that contain the attribute
  * @param array $data The data of the select
  * @return string
  */
 public function selectStatic($params, $data = [])
 {
     if (!is_array($params)) {
         $attribute = $params;
         $params = [];
         $params[] = $attribute;
         $params['class'] = 'form-control';
     } else {
         $attribute = $params[0];
         if (!isset($params['class'])) {
             $params['class'] = 'form-control';
         } else {
             $params['class'] .= ' form-control';
         }
     }
     if ($this->hasError($attribute)) {
         $div_class = 'form-group has-error';
         $error = $this->createErorr($attribute);
     } else {
         $div_class = 'form-group';
         $error = '';
     }
     return $this->startDefault($div_class) . $this->label($attribute) . Tag::selectStatic($params, $data) . $error . $this->endDefault();
 }
开发者ID:wataridori,项目名称:bphalcon,代码行数:30,代码来源:BForm.php


注:本文中的Phalcon\Tag::selectStatic方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。