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


PHP FormHelper::radio方法代码示例

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


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

示例1: testRadio

 public function testRadio()
 {
     //test where valueOrArray is array
     $html = $this->object->radio('element', 'value', array('arbitrary' => 'arbitrary', 'class' => 'test-class'));
     $this->assertAttributes($html, array('class' => array('test-class', 'ccm-input-radio'), 'arbitrary' => 'arbitrary'));
     //test where valueOrArray is value
     $html = $this->object->radio('element', 'value', 'value', array('arbitrary' => 'arbitrary', 'class' => 'test-class'));
     $this->assertAttributes($html, array('class' => array('test-class', 'ccm-input-radio'), 'arbitrary' => 'arbitrary', 'checked' => 'checked'));
 }
开发者ID:notzen,项目名称:concrete5-tests,代码行数:9,代码来源:FormHelperTest.php

示例2: radio

 public function radio($fieldName, $radioOptions, $options)
 {
     $options['legend'] = false;
     $options['separator'] = "\n";
     $out = parent::radio($fieldName, $radioOptions, $options);
     $out = $this->_restructureLabel($out, array('class' => 'radio'));
     return $out;
 }
开发者ID:racklin,项目名称:TwitterBootstrap,代码行数:8,代码来源:BootstrapFormHelper.php

示例3: radio

 /**
  * Outputs a list of radio form elements with the proper
  * markup for twitter bootstrap styles
  *
  * @param array $options
  * @param array $attributes
  * @access public
  * @return string
  */
 public function radio($field, $options = array(), $attributes = array())
 {
     if (is_array($field)) {
         $options = $field;
     } else {
         $options["field"] = $field;
     }
     if (!isset($options["options"]) || !isset($options["field"])) {
         return "";
     }
     $opt = $options["options"];
     unset($options["options"]);
     $inputs = "";
     $hiddenField = isset($options['hiddenField']) && $options['hiddenField'];
     foreach ($opt as $key => $val) {
         $input = parent::radio($options["field"], array($key => $val), $attributes + array("label" => false, 'hiddenField' => $hiddenField));
         $id = array();
         preg_match_all("/id=\"[a-zA-Z0-9_-]*\"/", $input, $id);
         if (!empty($id[0])) {
             $id = end($id[0]);
             $id = substr($id, 4);
             $id = substr($id, 0, -1);
             $input = $this->Html->tag("label", $input, array("class" => "radio", "for" => $id));
         }
         $inputs .= $input;
     }
     $options["input"] = $inputs;
     return $this->input($options);
 }
开发者ID:Asdafers,项目名称:MyAL,代码行数:38,代码来源:BootstrapHelper.php

示例4: radio

 /**
  * radio method override for purchasable option
  *
  * ex.
  * echo $this->Form->input('Category.Category', array(
  *    'type' => 'radio',
  *    'purchasable' => true, // must be set to true
  *    'combine' => array('{n}.Category.id', '{n}.Category.name'), // what the
  * list should look like
  *    'options' => $categories  // a full data array from find "all", not a
  * normal find "list" type
  *    ));
  *
  */
 public function radio($fieldName, $options = array(), $attributes = array())
 {
     if ($attributes['purchasable'] === true && !empty($attributes['combine'])) {
         $combine = explode('.', $attributes['combine'][0]);
         $key = $combine[2];
         $combine = explode('.', $attributes['combine'][1]);
         $model = $combine[1];
         $value = $combine[2];
         unset($attributes['purchasable']);
         unset($attributes['combine']);
         $out = '';
         for ($i = 0; $i < count($options); $i++) {
             $id = $options[$i][$model][$key];
             $label = $options[$i][$model][$value];
             if ($i > 0) {
                 $attributes['hiddenField'] = false;
                 // because we're doing individual radio buttons we need to remove all but the
                 // first hidden field as it would be normally
             }
             if (!empty($options[$i]['Product']) && empty($options[$i]['TransactionItem'])) {
                 // must be purchased, and hasn't been yet (in the
                 // Products/Model/Behavior/PurchasableBehavior)
                 $out .= parent::radio($fieldName, array($id => __('<span style="text-decoration: line-through">%s</span> <a href="/products/products/view/%s" class="btn btn-mini btn-success">Buy</a>', $label, $options[$i]['Product']['id'])), $attributes + array('disabled' => 'disabled'));
             } else {
                 $out .= parent::radio($fieldName, array($id => $label), $attributes);
             }
         }
         //$options = Set::combine($options, $attributes['combine'][0],
         // $attributes['combine'][1]);
         return $out;
     } else {
         return parent::radio($fieldName, $options, $attributes);
     }
 }
开发者ID:ajayphp,项目名称:Zuha,代码行数:48,代码来源:ZuhaFormHelper.php

示例5: testRadio

 public function testRadio()
 {
     $this->assertEqual(FormHelper::radio('name', 'value', null, array('class' => 'myClass')), '<input type="radio" name="name" class="myClass" value="value">');
     $this->assertEqual(FormHelper::radio('name', 'value', 'value', array('class' => 'myClass')), '<input type="radio" name="name" class="myClass" value="value" checked="checked">');
     $this->assertEqual(FormHelper::radio('name', $this->Model, 'obj', array('class' => 'myClass')), '<input type="radio" name="name" class="myClass" value="obj" checked="checked">');
 }
开发者ID:nicolasmartin,项目名称:framework,代码行数:6,代码来源:helper.form.php

示例6: radio

 /**
  * Creates a set of radio widgets.
  *
  * ### Attributes:
  *
  * - `label` - Create a label element for the radio buttons in the left column
  * - `value` - indicate a value that is should be checked
  * - `disabled` - Set to `true` or `disabled` to disable all the radio buttons.
  * - `help` - Add a message under the radio buttons to give more informations
  * - `inline` - Align all the radio buttons
  *
  * @param string $fieldName Name of a field, like this "Modelname.fieldname"
  * @param array $options Radio button options array (as 'value'=>'Text' pairs or as array('label' => 'text', 'help' => 'informations')
  * @param array $attributes Array of HTML attributes, and special attributes above.
  * @return string Completed radio widget set.
  */
 public function radio($fieldName, $options = array(), $attributes = array())
 {
     $out = '';
     $inline = isset($attributes['inline']) && true === $attributes['inline'] ? true : false;
     unset($attributes['inline']);
     $defaultAttributes = array('legend' => false, 'label' => false);
     $defaultAttributes['separator'] = $inline ? '</label><label class="radio-inline">' : '</label></div><div class="radio"><label>';
     $attributes = $this->__errorBootstrap($fieldName, $attributes);
     $attributes = Hash::merge($defaultAttributes, $attributes);
     $attributesForBefore = $attributes;
     unset($attributes['state']);
     unset($attributes['help']);
     $attributes['label'] = false;
     $radio = parent::radio($fieldName, $options, $attributes);
     return $this->__buildRadioBefore($fieldName, $attributesForBefore, $inline) . $radio . $this->__buildRadioAfter($inline, $attributesForBefore);
 }
开发者ID:xhs345,项目名称:CakePHP-BsHelpers,代码行数:32,代码来源:BsFormHelper.php

示例7: radio

 /**
  * FormExtHelper::radio()
  * Overwrite to avoid "form-control" to be added.
  *
  * @param mixed $fieldName
  * @param mixed $options
  * @param mixed $attributes
  * @return void
  */
 public function radio($fieldName, $options = array(), $attributes = array())
 {
     $attributes = $this->_initInputField($fieldName, $attributes);
     if (!empty($attributes['class']) && $attributes['class'] == array('form-control')) {
         $attributes['class'] = false;
     }
     return parent::radio($fieldName, $options, $attributes);
 }
开发者ID:miznokruge,项目名称:base-cake,代码行数:17,代码来源:FormExtHelper.php


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