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


PHP Select::render方法代码示例

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


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

示例1: testRender

 /**
  * @covers Xoops\Form\Select::render
  * @todo   Implement testRender().
  */
 public function testRender()
 {
     $this->object->addOptionArray(array('opt_key' => 'opt_name', 'opt_just_key' => null));
     $value = $this->object->render();
     $this->assertTrue(is_string($value));
     $this->assertTrue(false !== strpos($value, '<select'));
     $this->assertTrue(false !== strpos($value, 'name="name"'));
     $this->assertTrue(false !== strpos($value, 'size="1"'));
     $this->assertTrue(false !== strpos($value, 'title="Caption"'));
     $this->assertTrue(false !== strpos($value, 'id="name"'));
     $this->assertTrue(false !== strpos($value, '<option'));
     $this->assertTrue(false !== strpos($value, 'value="opt_key"'));
     $this->assertTrue(false !== strpos($value, '>opt_name</option>'));
     $this->assertTrue(false !== strpos($value, 'value="opt_just_key"'));
     $this->assertTrue(false !== strpos($value, '>opt_just_key</option>'));
     $this->object = new Select('Caption', 'name', 'value');
     // reset object
     $groups = array('grp_key' => 'grp_name', 'grp_key1' => 'grp_name1');
     $this->object->addOptgroup('opt_grp_name', $groups);
     $value = $this->object->render();
     $this->assertTrue(is_string($value));
     $this->assertTrue(false !== strpos($value, '<select'));
     $this->assertTrue(false !== strpos($value, 'name="name"'));
     $this->assertTrue(false !== strpos($value, 'size="1"'));
     $this->assertTrue(false !== strpos($value, 'title="Caption"'));
     $this->assertTrue(false !== strpos($value, 'id="name"'));
     $this->assertTrue(false !== strpos($value, '<optgroup'));
     $this->assertTrue(false !== strpos($value, 'label="opt_grp_name"'));
     $this->assertTrue(false !== strpos($value, '<option'));
     $this->assertTrue(false !== strpos($value, 'value="grp_key"'));
     $this->assertTrue(false !== strpos($value, '>grp_name</option>'));
     $this->assertTrue(false !== strpos($value, 'value="grp_key1"'));
     $this->assertTrue(false !== strpos($value, '>grp_name1</option>'));
 }
开发者ID:redmexico,项目名称:XoopsCore,代码行数:38,代码来源:SelectTest.php

示例2: render

 public function render()
 {
     $name = $this->get('name');
     if (substr($name, -2) !== '[]') {
         $this->set('name', $name . '[]');
     }
     return parent::render();
 }
开发者ID:irfanevrens,项目名称:html,代码行数:8,代码来源:MultiSelect.php

示例3: it_renders_with_options_the_full_html

 /** @test */
 public function it_renders_with_options_the_full_html()
 {
     $field = new Select('test', 'Test', ['values' => ['miro' => 'test']]);
     $field->render();
     $options = $field->options();
     $this->assertCount(1, $options);
     $this->assertInstanceOf(Option::class, $options[0]);
 }
开发者ID:administrcms,项目名称:form,代码行数:9,代码来源:SelectFieldTest.php

示例4: render

 public function render()
 {
     $options = [];
     foreach (range($this->min, $this->max) as $year) {
         $options[$year] = $year;
     }
     $this->setOptions($options);
     return parent::render();
 }
开发者ID:hpolthof,项目名称:admin,代码行数:9,代码来源:Year.php

示例5: render

 public function render()
 {
     // check if we have options
     if ($this->options == null) {
         // if we don't have options, we set only 'yes' and 'no'
         $this->setOptions($this->getYesNo());
     } else {
         // if options is set, it means that a options['select'] is given
         // we combine it with yes/no
         $this->setOptions($this->options += $this->getYesNo());
     }
     return parent::render();
 }
开发者ID:Clansuite,项目名称:Clansuite,代码行数:13,代码来源:SelectYesNo.php

示例6: render

 public function render()
 {
     $args = array();
     if (!empty($this->attributes['args'])) {
         $args = $this->attributes['args'];
     }
     $terms = get_terms($this->attributes['taxonomies'], $args);
     $options = array();
     if (!empty($this->attributes['options'])) {
         $options = $this->attributes['options'];
     }
     foreach ($terms as $term) {
         $options[$term->term_id] = $term->name;
     }
     $this->attributes['options'] = $options;
     parent::render();
 }
开发者ID:loumray,项目名称:wpforms,代码行数:17,代码来源:SelectTerm.php

示例7: render

 /**
  * Representação textual da query
  *
  * @return string
  * */
 public function render()
 {
     return $this->_select->render();
 }
开发者ID:sgdoc,项目名称:sgdoce-codigo,代码行数:9,代码来源:Query.php

示例8: render

 /**
  * @param  string $name        The element name
  * @param  string $value       The time displayed in this widget
  * @param  array  $attributes  An array of HTML attributes to be merged with the default HTML attributes
  * @param  array  $errors      An array of errors for the field
  *
  * @return string An HTML tag string
  *
  * @see sfWidgetForm
  */
 public function render($name, $value = null, $attributes = array(), $errors = array())
 {
     // convert value to an array
     $default = array('hour' => null, 'minute' => null, 'second' => null);
     if (is_array($value)) {
         $value = array_merge($default, $value);
     } else {
         $value = ctype_digit($value) ? (int) $value : strtotime($value);
         if (false === $value) {
             $value = $default;
         } else {
             // int cast required to get rid of leading zeros
             $value = array('hour' => (int) date('H', $value), 'minute' => (int) date('i', $value), 'second' => (int) date('s', $value));
         }
     }
     $time = array();
     $emptyValues = $this->getOption('empty_values');
     // hours
     $widget = new Select(array('choices' => $this->getOption('can_be_empty') ? array('' => $emptyValues['hour']) + $this->getOption('hours') : $this->getOption('hours')), array_merge($this->attributes, $attributes));
     $time['%hour%'] = $widget->render($name . '[hour]', $value['hour']);
     // minutes
     $widget = new Select(array('choices' => $this->getOption('can_be_empty') ? array('' => $emptyValues['minute']) + $this->getOption('minutes') : $this->getOption('minutes')), array_merge($this->attributes, $attributes));
     $time['%minute%'] = $widget->render($name . '[minute]', $value['minute']);
     if ($this->getOption('with_seconds')) {
         // seconds
         $widget = new Select(array('choices' => $this->getOption('can_be_empty') ? array('' => $emptyValues['second']) + $this->getOption('seconds') : $this->getOption('seconds')), array_merge($this->attributes, $attributes));
         $time['%second%'] = $widget->render($name . '[second]', $value['second']);
     }
     return strtr($this->getOption('with_seconds') ? $this->getOption('format') : $this->getOption('format_without_seconds'), $time);
 }
开发者ID:rande,项目名称:sfFormBundle,代码行数:40,代码来源:Time.php

示例9: prepareSmarty

 /**
  * Display this class
  */
 private function prepareSmarty()
 {
     $this->smarty = new Template();
     $this->smarty->assign('heading', $this->file->filename);
     $this->smarty->assign('title', $this->file->filename);
     $this->smarty->assign('file', $this->file);
     $this->smarty->requireResource('file');
     $select = new Select('permission', '', FilePermissions::getAll());
     $select->selected_value = $this->file->permission;
     $this->smarty->assign('permission', $select->render());
 }
开发者ID:nicefirework,项目名称:sharecloud,代码行数:14,代码来源:HandlerBase.class.php

示例10: test__construct

 /**
  * @covers Xoops\Form\Select::__construct
  * @covers Xoops\Form\Select::render
  * @covers Xoops\Form\Select::renderValidationJS
  */
 public function test__construct()
 {
     $oldWay = new Select('mycaption', 'myname', 'opt1');
     $oldWay->addOption('opt1', 'optname1');
     $oldWay->addOption('opt2', 'optname2');
     $newWay = new Select(['caption' => 'mycaption', 'name' => 'myname', 'value' => 'opt1', 'option' => ['opt1' => 'optname1', 'opt2' => 'optname2']]);
     $this->assertEquals($oldWay->render(), $newWay->render());
     $this->assertEquals($oldWay->renderValidationJS(), $newWay->renderValidationJS());
 }
开发者ID:ming-hai,项目名称:XoopsCore,代码行数:14,代码来源:SelectTest.php

示例11: testInput

 public function testInput()
 {
     $select = new Select(['name' => "name"]);
     $select->addOptions([1 => "Valor", 2 => "Valor 2"]);
     $this->assertEquals($select->render(), '<div><select name="name"><option value="1">Valor</option><option value="2">Valor 2</option></select></div>');
 }
开发者ID:LeandroSenni,项目名称:Code.Education.DesignPatterns,代码行数:6,代码来源:SelectTest.php

示例12: render

 public function render()
 {
     $files = $this->getFiles();
     // set "images" hardcoded to identify the select options and append the Name
     parent::setID('images_' . $this->getNameWithoutBrackets());
     if (empty($files)) {
         $this->html = 'There are no images in "' . $this->getDirectory() . '" to select. Please upload some.';
     } else {
         $this->setOptions($files);
         // @todo first image is not displayed... display it.
         // Watch out!
         // the div images/preview must be present in the dom, before you assign js function to it via $('#image')
         $javascript = '<script type="text/javascript">
                        $(document).ready(function () {
                           $("#images_' . $this->getNameWithoutBrackets() . '").change(function () {
                                 var src = $("option:selected", this).val();
                                 $("#imagePreview_' . $this->getNameWithoutBrackets() . '").html(
                                     src ? "<img src=\'" + src + "\'>" : ""
                                 );
                             });
                         });
                         </script>';
         $html = parent::render() . CR . '<div id="imagePreview_' . $this->getNameWithoutBrackets() . '"></div>';
         $this->html = $html . $javascript;
     }
     return $this->html;
 }
开发者ID:ksst,项目名称:kf,代码行数:27,代码来源:JqSelectImage.php

示例13: renderYearWidget

 /**
  * @param string $name
  * @param string $value
  * @param array $options
  * @param array $attributes
  * @return string rendered widget
  */
 protected function renderYearWidget($name, $value, $options, $attributes)
 {
     $widget = new Select($options, $attributes);
     return $widget->render($name, $value);
 }
开发者ID:rande,项目名称:sfFormBundle,代码行数:12,代码来源:Date.php

示例14: get_select

/**
 * Select getter Function
 * @see skip_select()
 * @ignore
 */
function get_select($name, $elements, $label = FALSE, $args = array(), $return = 'html')
{
    $select = new Select($name, $label, $args);
    if (count($elements) > 0) {
        if (is_array($elements)) {
            foreach ($elements as $element) {
                $select->add_element($element);
            }
        } else {
            $values = explode(',', $elements);
            foreach ($values as $value) {
                $select->add_element(array('value' => $value));
            }
        }
    }
    return $select->render();
}
开发者ID:antoniorequenalorente,项目名称:Fanpage-import,代码行数:22,代码来源:select.php


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