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


PHP Select::addOptionArray方法代码示例

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


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

示例1: __construct

 /**
  * __construct
  *
  * @param string  $caption  caption
  * @param string  $name     name
  * @param integer $size     size
  * @param integer $value    value unix timestamp
  * @param boolean $showtime true to show time, false for date only
  */
 public function __construct($caption, $name, $size = 2, $value = 0, $showtime = true)
 {
     parent::__construct($caption, '');
     $value = (int) $value;
     $value = $value > 0 ? $value : time();
     $datetime = getdate($value);
     $date = new DateSelect('', $name . '[date]', $size, $value);
     $date->setAttribute('id', $name . '-date');
     $this->addElement($date);
     if ($showtime) {
         $timearray = array();
         for ($i = 0; $i < 24; ++$i) {
             for ($j = 0; $j < 60; $j = $j + 10) {
                 $key = $i * 3600 + $j * 60;
                 $timearray[$key] = $j != 0 ? $i . ':' . $j : $i . ':0' . $j;
             }
         }
         ksort($timearray);
         $timeselect = new Select('', $name . '[time]', $datetime['hours'] * 3600 + 600 * ceil($datetime['minutes'] / 10));
         $timeselect->setAttribute('id', $name . '-time');
         $timeselect->addOptionArray($timearray);
         $timeselect->setClass('span2');
         $this->addElement($timeselect);
     } else {
         $this->addElement(new Hidden($name . '[time]', 0));
     }
 }
开发者ID:redmexico,项目名称:XoopsCore,代码行数:36,代码来源:DateTime.php

示例2: 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

示例3: render

 /**
  * render
  *
  * @return string
  */
 public function render()
 {
     $editor_handler = \XoopsEditorHandler::getInstance();
     $editor_handler->allowed_editors = $this->allowed_editors;
     $option_select = new Select("", $this->name, $this->value);
     $onchangeCode = '"if(this.options[this.selectedIndex].value.length > 0 ){window.document.forms.' . $this->form->getName() . '.submit();}"';
     $option_select->set('onchange', $onchangeCode);
     $option_select->addOptionArray($editor_handler->getList($this->nohtml));
     $this->addElement($option_select);
     return parent::render();
 }
开发者ID:ming-hai,项目名称:XoopsCore,代码行数:16,代码来源:SelectEditor.php


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