select() public method

public select ( $name, $options = [] )
コード例 #1
0
 public function testSelect()
 {
     $this->assertEqual(FormHelper::select('name', array('1' => 'un', '2' => 'deux'), '1', array('class' => 'myClass')), '<select name="name" class="myClass" id="name">' . '<option value="1" selected="selected">un</option>' . '<option value="2">deux</option>' . '</select>');
     $this->assertEqual(FormHelper::select('name', array('1' => 'un', '2' => 'deux'), array('1', '2'), array('class' => 'myClass')), '<select name="name" class="myClass" id="name">' . '<option value="1" selected="selected">un</option>' . '<option value="2" selected="selected">deux</option>' . '</select>');
     $this->assertEqual(FormHelper::select('name', array('1' => 'un', '2' => 'deux'), array('1', '2'), array('empty' => '-- select --', 'class' => 'myClass')), '<select name="name" class="myClass" id="name">' . '<option value="">-- select --</option>' . '<option value="1" selected="selected">un</option>' . '<option value="2" selected="selected">deux</option>' . '</select>');
     $this->assertEqual(FormHelper::select('name', array('obj' => 'un', '2' => 'deux'), $this->Model, array('class' => 'myClass')), '<select name="name" class="myClass" id="name">' . '<option value="obj" selected="selected">un</option>' . '<option value="2">deux</option>' . '</select>');
 }
コード例 #2
0
 public function testSelect()
 {
     $options = array('1' => 'One', '2' => 'Two', '3' => 'Three');
     //test where valueOrArray is array
     $html = $this->object->select('element', $options, array('arbitrary' => 'arbitrary', 'class' => 'test-class'));
     $this->assertAttributes(substr($html, 0, strpos($html, '<option')), array('class' => array('test-class', 'ccm-input-select'), 'arbitrary' => 'arbitrary'));
     //test where valueOrArray is value
     $html = $this->object->select('element', $options, '3', array('arbitrary' => 'arbitrary', 'class' => 'test-class'));
     $this->assertAttributes(substr($html, 0, strpos($html, '<option')), array('class' => array('test-class', 'ccm-input-select'), 'arbitrary' => 'arbitrary', 'ccm-passed-value' => '3'));
     $html = substr($html, strpos($html, 'option value="3"'));
     $html = substr($html, 0, strpos($html, '</option'));
     $this->assertContains('selected', $html);
 }
コード例 #3
0
 public function select($fieldName, $options = array(), $attributes = array())
 {
     $multiple = $this->_extractOption('multiple', $attributes);
     $checkbox = explode(' ', $multiple);
     $attributes['multiple'] = $checkbox[0];
     $out = parent::select($fieldName, $options, $attributes);
     if ('checkbox' === $checkbox[0]) {
         $out = $this->_restructureLabel($out, array('class' => $multiple));
     }
     return $out;
 }
コード例 #4
0
 public function select($fieldName, $options = array(), $attributes = array())
 {
     $select_source = parent::select($fieldName, $options, $attributes);
     if (!isset($attributes['multiple']) || isset($attributes['multiple']) && $attributes['multiple'] !== 'checkbox') {
         $js = '$("#' . $this->domId($fieldName) . '").select2();';
         echo $this->Html->script('/CakeUI/js/select2-3.4.8/select2.min', array('inline' => false));
         if (empty($this->once['/CakeUI/css/select2-3.4.8/select2.css']) && empty($this->once['/CakeUI/css/select2-3.4.8/select2-bootstrap.css'])) {
             $this->once['/CakeUI/css/select2-3.4.8/select2.css'] = true;
             $this->once['/CakeUI/css/select2-3.4.8/select2-bootstrap.css'] = true;
             echo $this->Html->css(array('/CakeUI/css/select2-3.4.8/select2.css', '/CakeUI/css/select2-3.4.8/select2-bootstrap.css'), null, array('inline' => false));
         }
         echo $this->Html->scriptBlock($js, array('inline' => false));
     }
     return $select_source;
 }
コード例 #5
0
ファイル: ZuhaFormHelper.php プロジェクト: ajayphp/Zuha
    /**
     *  Added by Zuha to parse extra fields needed for ajax
     */
    public function select($fieldName, $options = array(), $attributes = array())
    {
        // Added by Zuha to parse extra fields needed for ajax
        if (isset($attributes['ajax'])) {
            $attributes = $this->ajaxElement($attributes);
        }
        $selectElement = parent::select($fieldName, $options, $attributes);
        if (isset($attributes['limit']) && $attributes['multiple'] == 'checkbox') {
            $matches = explode('.', $fieldName);
            $name = 'data';
            foreach ($matches as $match) {
                $name .= '[' . $match . ']';
            }
            $name .= '[]';
            $selectElement .= '
				<script type="text/javascript">
					$(document).ready(function() {
					  $("input[name=\'' . $name . '\'").click(function() {
					    if ( $("input[name=\'' . $name . '\']:checked").length > ' . $attributes['limit'] . ' ) {
					      alert("You may only choose a maximum of ' . $attributes['limit'] . '");
					      $(this).prop("checked", false);
					    }
					  });
					});
				</script>';
        }
        return $selectElement;
    }
コード例 #6
0
ファイル: mi_form.php プロジェクト: hiromi2424/mi
    /**
     * select - or autocomplete
     *
     * @param mixed $fieldName
     * @param array $options array()
     * @param mixed $selected null
     * @param array $attributes array()
     * @return void
     * @access public
     */
    function select($fieldName, $options = array(), $selected = null, $attributes = array())
    {
        $ac = array();
        if (array_key_exists('--autocomplete--', $options)) {
            $ac = $options['--autocomplete--'];
            unset($options['--autocomplete--']);
        }
        if (count($options) > 1 || $ac === false) {
            return parent::select($fieldName, $options, $selected, $attributes);
        }
        $ac = array_merge(array('class' => 'autocomplete', 'source' => null, 'hiddenField' => null, 'writeJs' => true), (array) $ac);
        if (!$ac['hiddenField']) {
            if (is_null($ac['hiddenField']) && substr($fieldName, -3) == '_id') {
                $ac['hiddenField'] = true;
            }
        }
        $hiddenOptions = $this->_initInputField($fieldName, array('secure' => false));
        if ($ac['hiddenField']) {
            $hidden = $this->hidden($fieldName, $hiddenOptions);
            $suffix = '_auto';
        } else {
            $suffix = $hidden = '';
        }
        if ($ac['class']) {
            if (!empty($attributes['class'])) {
                $attributes['class'] .= ' ' . $ac['class'];
            } else {
                $attributes['class'] = $ac['class'];
            }
        }
        $attributes = $this->_initInputField($fieldName . $suffix, array_merge(array('type' => 'text'), $attributes));
        if (array_key_exists('label', $ac)) {
            $attributes['value'] = $ac['label'];
        } elseif ($selected && array_key_exists($selected, $options)) {
            $attributes['value'] = $options[$selected];
        } elseif (!empty($hiddenOptions['value']) && array_key_exists($hiddenOptions['value'], $options)) {
            $attributes['value'] = $options[$hiddenOptions['value']];
        } elseif ($hiddenOptions['value']) {
            $attributes['value'] = '(' . $hiddenOptions['value'] . ')';
        }
        $input = sprintf($this->Html->tags['input'], $attributes['name'], $this->_parseAttributes($attributes, array('name'), null, ' '));
        if ($ac['writeJs']) {
            if (!empty($ac['source'])) {
                $source = $ac['source'];
                if (is_array($source)) {
                    if (isset($source['action'])) {
                        $url = $this->url($source);
                        $source = 'function (request, response) {
							$.getJSON("' . $url . '/" + request["term"] + ".json", {}, response );
						}';
                    } else {
                        $source = json_encode($source, true);
                    }
                } else {
                    $source = '"' . $this->url($source) . '"';
                }
            } else {
                if (substr($fieldName, -3) == '_id') {
                    $fieldName = substr($fieldName, 0, strlen($fieldName) - 3);
                }
                if (strpos($fieldName, '.') && ($fieldName[0] = strtoupper($fieldName[0]))) {
                    $bits = explode('.', $fieldName);
                    $model = array_shift($bits);
                    $fieldName = array_shift($bits);
                    if ($bits && is_numeric($fieldName)) {
                        $fieldName = array_shift($bits);
                    }
                }
                if ($fieldName === 'parent') {
                    if (!empty($model)) {
                        $controller = Inflector::pluralize($model);
                    } else {
                        $controller = $this->params['controller'];
                    }
                } else {
                    $controller = Inflector::pluralize($fieldName);
                }
                $url = $this->url(array('controller' => $controller, 'action' => 'lookup'));
                $source = 'function (request, response) {
					$.getJSON("' . $url . '/" + request["term"] + ".json", {}, response );
				}';
            }
            if (isset($this->Asset)) {
                $this->Asset->js('jquery-ui', $this->name);
                $this->Asset->codeBlock('$(document).ready(function() {
						$("#' . $attributes['id'] . '").autocomplete({
								source: ' . $source . ($ac['hiddenField'] ? ',
								change: function(event, ui) {
									if ($("#' . $attributes['id'] . '").text() == "") {
										$("#' . $hiddenOptions['id'] . '").val("");
									}
								},
								select: function(event, ui) {
									$("#' . $hiddenOptions['id'] . '").val(ui.item.id);
									$("#' . $attributes['id'] . '").text(ui.item.label);
								}' : '') . '
							});
					});');
            }
        }
        return $hidden . $input;
    }
コード例 #7
0
 function select($fieldName, $options = array(), $selected = null, $attributes = array())
 {
     if (isset($attributes) && array_key_exists('multiple', $attributes) && $attributes['multiple'] === false) {
         unset($attributes['multiple']);
     }
     $res = parent::select($fieldName, $options, $selected, $attributes);
     if (!empty($attributes['multiple']) && array_key_exists('hiddenField', $attributes) && !$attributes['hiddenField']) {
         $parts = explode("\n", $res, 2);
         $res = $parts[1];
     }
     return $res;
 }
コード例 #8
0
<?php

$classRequired = $divClassOverride ? $divClassOverride : 'user-or-hash-wrapper';
$form = new FormHelper();
?>
<div class="<?php 
echo $classRequired;
?>
">
  <?php 
echo $form->select('userOrHash[]', $userTimelineOrHashSelectArray, $type);
?>
  <?php 
echo $form->text('userOrHashValue[]', $value, array('style' => 'size:40;'));
?>
  <a class="setting-remove"><img src="<?php 
echo $this->getBlockUrl();
?>
/images/delete.png" alt='<?php 
echo t("delete");
?>
' title='<?php 
echo t("delete");
?>
' width='16' height='16' style='vertical-align: middle;' /></a>
  <?php 
if (false && $lastSetting) {
    ?>
    <a href="#" class="add-timeline-component" id="add-timeline-component-button"><img src="<?php 
    echo $this->getBlockUrl();
    ?>
コード例 #9
0
ファイル: extended_form.php プロジェクト: hafizubikm/bakeme
 function select($fieldName, $options = array(), $selected = null, $attributes = array(), $showEmpty = '')
 {
     $attributes = $this->_initInputField($fieldName, $attributes);
     $code = parent::select($fieldName, $options, $selected, $attributes, $showEmpty);
     if (!empty($attributes['autocomplete']) && $attributes['autocomplete'] == true) {
         $code .= "<script type=\"text/javascript\">\n";
         $code .= "var {$attributes['id']}Data = new Array();\n";
         $code .= "\$('#{$attributes['id']}').before('<input type=\"text\" id=\"{$attributes['id']}Text\" />');\n";
         $code .= "\$('#{$attributes['id']}').css('display', 'none');\n";
         $code .= "\$('#{$attributes['id']} option').each(function(i){\n";
         $code .= "{$attributes['id']}Data.push({label: this.innerHTML, value: this.value});\n";
         $code .= "if(\$('#{$attributes['id']}').val() == this.value) \$('#{$attributes['id']}Text').val(this.innerHTML);\n";
         $code .= "});\n";
         $code .= "\$('#{$attributes['id']}Text').autocomplete({$attributes['id']}Data, {\n";
         $code .= "max: 20,\n";
         $code .= "matchContains: true,\n";
         $code .= "formatItem: function(item) {\n";
         $code .= "return item.label;\n";
         $code .= "}\n";
         $code .= "}).result(function(event, item) {\n";
         $code .= "\$('#{$attributes['id']}').val(item.value);\n";
         $code .= "\$('#{$attributes['id']}').change();\n";
         $code .= "});\n";
         $code .= "</script>\n";
     }
     return $code;
 }
コード例 #10
0
 /**
  * Dynamically replace the field tags with their labels/form field equivalents
  */
 function afterFilter()
 {
     $output =& $this->output;
     $names = array();
     $labels = array();
     $select = array();
     $cat_tag = false;
     $date_field = false;
     $cat_auto = Sanitize::getInt($this->params['module'], 'cat_auto');
     $dir_id = $section_id = $cat_id = $criteria_id = '';
     # Initialize FormHelper
     $Form = new FormHelper();
     $CustomFields = new CustomFieldsHelper();
     $CustomFields->Config =& $this->Config;
     # Process custom field tag attributes
     foreach ($this->fieldTags as $key => $value) {
         $var = explode('|', $value);
         if (!strstr($value, '_label')) {
             $names[$var[0]] = $value;
         } elseif (strstr($value, '_label')) {
             $labels[] = substr($value, 0, -6);
         }
         if ($value == 'category') {
             $cat_tag = true;
             /************************/
             if (isset($var[1]) && $var[1] == 'm') {
                 $category_select_type = ' multiple="multiple"';
             }
             if (isset($var[2]) && (int) $var[2] > 0) {
                 $category_select_size = ' size="' . $var[2] . '"';
             }
             /************************/
         }
         if (isset($var[1]) && strtolower($var[1]) == 'm') {
             $select[$var[0]] = 'selectmultiple';
         } elseif (isset($var[1]) && strtolower($var[1]) == 's') {
             $select[$var[0]] = 'select';
         }
         $select_size[$var[0]] = isset($var[2]) ? $var[2] : 5;
         # Check for category select list
         if ($var[0] == 'category') {
             if (isset($var[1]) && strtolower($var[1]) == 's') {
                 $category_select_type = ' multiple="multiple"';
             }
             if (isset($var[2]) && (int) $var[2] > 0) {
                 $category_select_size = ' size="' . $var[2] . '"';
             }
         }
     }
     # Get selected values from url
     $entry = array();
     foreach ($this->params as $key => $value) {
         if (substr($key, 0, 3) == 'jr_') {
             $entry['Field']['pairs'][$key]['value'] = explode('_', $value);
         }
         // Add categories/sections
     }
     if (isset($this->params['tag'])) {
         $entry['Field']['pairs']['jr_' . $this->params['tag']['field']]['value'] = array($this->params['tag']['value']);
     }
     # Generate category list if tag found in view
     if ($cat_tag) {
         # Get module params before auto-detect
         $param_cat_id = Sanitize::getString($this->params['module'], 'cat_id');
         $param_dir_id = Sanitize::getString($this->params['module'], 'dir_id');
         $param_type_id = Sanitize::getString($this->params['module'], 'criteria_id');
         # Category auto detect
         $ids = CommonController::_discoverIDs($this);
         if ($cat_auto) {
             extract($ids);
         } elseif ($this->cmsVersion != CMS_JOOMLA15) {
             isset($ids['cat_id']) and $cat_id = $ids['cat_id'];
         }
         if ($this->cmsVersion == CMS_JOOMLA15 && $section_id == '' && $cat_id != '') {
             $sql = "SELECT section FROM #__categories WHERE id IN (" . $cat_id . ")";
             $this->_db->setQuery($sql);
             $section_id = $this->_db->loadResult();
         }
         $cat_id != '' and $this->params['module']['cat_id'] = $cat_id;
         $cat_id == '' and $section_id != '' and $this->params['module']['section_id'] = $section_id;
         $cat_id == '' and $criteria_id != '' and $this->params['module']['criteria_id'] = $criteria_id;
         if ($this->cmsVersion == CMS_JOOMLA15) {
             $categorySelect = $this->Category->categoryTree($this->_user->gid, $this->params);
         } else {
             $options = array('disabled' => false, 'cat_id' => !empty($param_cat_id) && !$cat_auto ? $param_cat_id : ($cat_auto ? $cat_id : ''), 'parent_id' => !empty($param_cat_id) && !$cat_auto ? $param_cat_id : ($cat_auto ? $cat_id : ''), 'dir_id' => !empty($param_dir_id) && !$cat_auto ? $param_dir_id : ($cat_auto ? $dir_id : ''), 'type_id' => !empty($param_type_id) && !$cat_auto ? $param_type_id : ($cat_auto ? $criteria_id : ''));
             if ($cat_auto && empty($options['cat_id'])) {
                 $options['level'] = 1;
             }
             $categories = $this->Category->getCategoryList($options);
             // Now get the parent and sibling categories
             if ($cat_auto && isset($categories[$cat_id]) && count($categories) == 1) {
                 $options['cat_id'] = $options['parent_id'] = $categories[$cat_id]->parent_id;
                 $categories = $this->Category->getCategoryList($options);
             }
             $categorySelect = $Form->select('data[categories]', array_merge(array(array('value' => null, 'text' => '- ' . __t("Select Category", true) . ' -')), $categories), $cat_id, array('class' => 'jrSelect'));
         }
         $output = str_replace('{' . $names['category'] . '}', $categorySelect, $output);
     }
     $fields = $this->Field->getFieldsArrayFromNames(array_keys($names), 'listing', $entry);
     # Replace label tags and change field type based on view atttributes
     if ($fields) {
         foreach ($fields as $key => $group) {
             foreach ($group['Fields'] as $name => $field) {
                 if (isset($select[$name])) {
                     $fields[$key]['Fields'][$name]['type'] = $select[$name];
                     $fields[$key]['Fields'][$name]['properties']['size'] = $select_size[$name];
                 } elseif ($fields[$key]['Fields'][$name]['type'] == 'textarea') {
                     $fields[$key]['Fields'][$name]['type'] = 'text';
                 }
                 if (in_array($name, $labels)) {
                     $output = str_replace('{' . $name . '_label}', $field['title'], $output);
                 }
                 if ($field['type'] == 'date') {
                     $date_field = true;
                 }
             }
         }
         $search = true;
         $location = 'listing';
         $CustomFields->form_id = Sanitize::getInt($this->params, 'module_id');
         $formFields = $CustomFields->getFormFields($fields, $location, $search, __t("Select", true));
         # Replace input tags
         foreach ($names as $key => $name) {
             if (isset($formFields["data[Field][Listing][{$key}]"])) {
                 $output = str_replace('{' . $names[$key] . '}', $formFields["data[Field][Listing][{$key}]"], $output);
             }
         }
         # Load js and css
         if ($date_field) {
             $Html = ClassRegistry::getClass('HtmlHelper');
             $Html->app = 'jreviews';
             $Libraries = ClassRegistry::getClass('LibrariesHelper');
             $Html->js(arrayFilter(array('jq.ui.core', 'jq.ui.datepicker'), $Libraries->js()));
             $Html->css(arrayFilter(array('jq.ui.core'), $Libraries->css()), false);
             ?>
             <script type="text/javascript">jreviews.datepicker();</script>
             <?php 
         }
     }
     return $output;
 }
コード例 #11
0
?>
">
					<label for="name">Titre de l'image</label>
					<?php 
echo FormHelper::text('name', $Picture, array('size' => 100));
?>
 
				</div>
	
				<div class="<?php 
echo ++$i % 2 ? 'odd' : 'even';
?>
">
					<label for="width">Taille</label>
					<?php 
echo FormHelper::select('percents', array('100' => '100%', '90' => ' 90%', '80' => ' 80%', '70' => ' 70%', '60' => ' 60%', '50' => ' 50%', '40' => ' 40%', '30' => ' 30%', '20' => ' 20%', '10' => ' 10%'), 100);
?>
					ou <?php 
echo FormHelper::text('width', '', array('size' => 4));
?>
 x <?php 
echo FormHelper::text('height', '', array('size' => 4));
?>
 px
				</div>
	
				<div class="<?php 
echo ++$i % 2 ? 'odd' : 'even';
?>
">
					<label for="alignment">Alignement</label>
コード例 #12
0
 public function select($fieldName, $options = array(), $attributes = array())
 {
     $defaults = array('empty' => '-- SELECT --');
     $defaults = Set::merge($this->_myInputDefaults, $defaults);
     $attributes = Set::merge($defaults, $attributes);
     return parent::select($fieldName, $options, $attributes);
 }
コード例 #13
0
 /**
  * Returns a formatted SELECT element.
  *
  * Extends of FormHelper::select() so get same attributes and params
  *
  * ### New Attributes:
  *
  * - `inline` - Only when attribute [multiple] is checkbox. Align all the checkboxes
  * - `help` - Add a message under the select element to give more informations
  * - 'label' - Add a label to the select element
  *
  * @param string $fieldName Name attribute of the SELECT
  * @param array $options Array of the OPTION elements (as 'value'=>'Text' pairs or as array('label' => 'text', 'help' => 'informations') in case of multiple checkbox) to be used in the
  *	SELECT element
  * @param array $attributes The HTML attributes of the select element.
  * @return string Formatted SELECT element
  */
 public function select($fieldName, $options = array(), $attributes = array())
 {
     $out = '';
     $isDate = false;
     $inline = isset($attributes['inline']) && ('inline' == $attributes['inline'] || true == $attributes['inline']) ? true : false;
     // MULTIPLE CHECKBOX
     if (isset($attributes['multiple']) && 'checkbox' != $attributes['multiple'] || !isset($attributes['multiple'])) {
         if (!isset($attributes['class'])) {
             $attributes['class'] = 'form-control';
         } else {
             $isDate = strpos($attributes['class'], 'input-date') !== false ? true : false;
             if (!$isDate) {
                 $attributes['class'] = 'form-control ' . $attributes['class'];
             }
         }
     } else {
         //----- [checkobx simple] attribute for checkbox
         if (!isset($attributes['class'])) {
             $attributes['class'] = 'checkbox';
         } else {
             $attributes['class'] = 'checkbox ' . $attributes['class'];
         }
     }
     //----- [empty] attribute
     if (!isset($attributes['empty'])) {
         $attributes['empty'] = false;
     }
     $attributes = $this->__errorBootstrap($fieldName, $attributes);
     $attributesForSelect = $attributes;
     // Clean
     unset($attributesForSelect['state']);
     unset($attributesForSelect['help']);
     unset($attributesForSelect['label']);
     $select = parent::select($fieldName, $options, $attributesForSelect);
     if ($isDate) {
         return $select;
     }
     $out .= $this->__buildSelectBefore($fieldName, $attributes);
     $out .= $select;
     $out .= $this->__buildSelectAfter($attributes);
     if (isset($attributes['multiple']) && 'checkbox' == $attributes['multiple']) {
         $regex = '/(<label for=.*?>)/';
         if (preg_match_all($regex, $out, $labels)) {
             foreach ($labels[0] as $label) {
                 $r1 = '/(<label.*.for="?)/';
                 $r2 = '/(".*>)/';
                 $field = preg_replace($r1, '', $label);
                 $field = preg_replace($r2, '', $field);
                 if ($inline) {
                     $r3 = '/(class=".*?)(.*")/';
                     if (preg_match($r3, $label, $labelClass)) {
                         $label = preg_replace($r3, $labelClass[1] . 'checkbox-inline ' . $attributes['class'] . ' ' . $labelClass[2], $label);
                     } else {
                         $r4 = '/(<label for="' . $field . '".*)(.*>)/';
                         $label = preg_replace($r4, '$1' . ' class="checkbox-inline" ' . '$2', $label);
                     }
                     $out = preg_replace('/(<div class="' . $attributes['class'] . '">)/', '', $out);
                     $out = preg_replace('/(<\\/label><\\/div>)/', '</label>', $out);
                 }
                 $out = preg_replace('/(<input type="checkbox".*)(.*id="' . $field . '".*?\\/>)/', $label . '$1' . '$2', $out);
                 $out = preg_replace('/(<input type="checkbox".*)(.*id="' . $field . '".*?\\/>)(<label for=.*?>)/', '$1' . '$2', $out);
             }
         }
     }
     return $out;
 }
コード例 #14
0
 /**
  * Returns a formatted SELECT element.
  *
  * Extends of FormHelper::select() so get same attributes and params
  *
  * ### New Attributes:
  *
  * - `inline` - Only when attribute [multiple] is checkbox. Align all the checkboxes
  * - `help` - Add a message under the select element to give more informations
  * - 'label' - Add a label to the select element
  *
  * @param string $fieldName Name attribute of the SELECT
  * @param array $options Array of the OPTION elements (as 'value'=>'Text' pairs or as array('label' => 'text', 'help' => 'informations') in case of multiple checkbox) to be used in the
  *	SELECT element
  * @param array $attributes The HTML attributes of the select element.
  * @return string Formatted SELECT element
  */
 public function select($fieldName, $options = array(), $attributes = array())
 {
     $out = '';
     // MULTIPLE CHECKBOX
     if (isset($attributes['multiple']) && $attributes['multiple'] != 'checkbox' || !isset($attributes['multiple'])) {
         if (!isset($attributes['class'])) {
             $attributes['class'] = 'form-control';
         } else {
             $attributes['class'] .= ' form-control';
         }
     } else {
         //----- [inline] attribute for checkbox
         if (isset($attributes['inline']) && ($attributes['inline'] == 'inline' || $attributes['inline'] == true)) {
             if (!isset($attributes['class'])) {
                 $attributes['class'] = 'checkbox checkbox-inline';
             } else {
                 $attributes['class'] = 'checkbox checkbox-inline ' . $attributes['class'];
             }
         } else {
             if (!isset($attributes['class'])) {
                 $attributes['class'] = 'checkbox';
             } else {
                 $attributes['class'] = 'checkbox ' . $attributes['class'];
             }
         }
     }
     //----- [empty] attribute
     if (!isset($attributes['empty'])) {
         $attributes['empty'] = false;
     }
     if ($this->_getFormType() == 'horizontal') {
         $out .= '<div class="form-group">';
         //----- [label] attribute
         if (isset($attributes['label']) && !empty($attributes['label'])) {
             $out .= '<label class="control-label col-md-' . $this->left . '">' . $attributes['label'] . '</label>';
             $out .= '<div class="col-md-' . $this->right . '">';
         } else {
             $out .= '<div class="col-md-offset-' . $this->left . ' col-md-' . $this->right . '">';
         }
     }
     $out .= parent::select($fieldName, $options, $attributes);
     if ($this->_getFormType() == 'horizontal') {
         //----- [help] attribute
         if (isset($attributes['help']) && !empty($attributes['help'])) {
             $out .= '<span class="help-block">' . $attributes['help'] . '</span>';
         }
         $out .= '</div></div>';
     }
     return $out;
 }
コード例 #15
0
 function select($fieldName, $options = array(), $selected = null, $attributes = array(), $showEmpty = '')
 {
     $locale = Configure::read('Config.language');
     switch ($locale) {
         case 'ja':
             $type = split('\\.', $fieldName);
             switch (array_pop($type)) {
                 case 'year':
                     foreach ($options as $key => $value) {
                         $options[$key] = $value . '年';
                     }
                     break;
                 case 'day':
                     foreach ($options as $key => $value) {
                         $options[$key] = $value . '日';
                     }
                     break;
             }
             break;
     }
     return parent::select($fieldName, $options, $selected, $attributes, $showEmpty);
 }