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


PHP Dropdown::appendOptionTitle方法代码示例

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


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

示例1: createDropdowns

 /**
  * create the dropdowns based on the previously set query or result array
  * @throws \Exception
  */
 protected function createDropdowns()
 {
     if (empty($this->data)) {
         throw new \Exception('Error creating dropdowns, because there are no results to create dropdowns from.');
     }
     // the separator we use to glue the values of the different columns together to ensure uniqueness
     $separator = '_';
     // collect all values with their parent value into $options
     $options = array();
     foreach ($this->data as $row) {
         $class = null;
         foreach ($row as $colname => $value) {
             // we store $class . $separator . $value instead of just $val, because it is possible that different level1's have same level2's
             // and by collecting this way, they will not get overwritten
             // Example: [ADSL2+][1. Geen mening]  and  [Fiber][1. Geen mening]
             $title = $class . $separator . $value;
             $options[$colname][$title] = array('value' => $value, 'label' => $value, 'class' => $class);
             $class = $title;
             // for the next column
         }
     }
     $selected = $this->getSelected();
     foreach ($options as $ddName => $ddOptionsAttributes) {
         // create the dropdown
         $dropdown = new Dropdown($ddName);
         $dropdown->setLabel(initcap($ddName));
         $dropdown->prependOption('', '-- all --');
         $dropdown->appendOptionClass('');
         // also add dummy values here
         $dropdown->appendOptionTitle('');
         // create the options with class and title
         foreach ($ddOptionsAttributes as $title => $attributes) {
             // add as option if label is not empty
             if (!empty($attributes['label'])) {
                 $dropdown->appendOption($attributes['value'], $attributes['label']);
                 // replace spaces and other invalid class characters with underscores
                 // based on the class we search for parent options with title equals that class, so title needs the same replacements
                 $dropdown->appendOptionClass($this->toValidHtmlId($attributes['class'], '_'));
                 $dropdown->appendOptionTitle($this->toValidHtmlId($title, '_'));
             }
         }
         // set the selected value
         if (is_array($selected) && sizeof($selected)) {
             $dropdown->setSelected(array_shift($selected));
         }
         // add to array of dropdowns
         $this->dropdowns[] = $dropdown;
     }
     // refresh the posted values
     if ($this->isPosted()) {
         $this->setPosted();
     }
 }
开发者ID:winkbrace,项目名称:winkform,代码行数:57,代码来源:ChainedDropdowns.php


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