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


PHP Html::activeRadio方法代码示例

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


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

示例1: run

 public function run()
 {
     if (is_null($this->id)) {
         if ($this->model instanceof Model) {
             $this->id = Html::getInputId($this->model, $this->attribute);
         } else {
             $this->id = $this->getId();
         }
     }
     if (is_null($this->name)) {
         if ($this->model instanceof Model) {
             $this->name = Html::getInputName($this->model, $this->attribute);
         } else {
             $this->name = $this->getId();
         }
     }
     $this->options['id'] = $this->id;
     $this->options['name'] = $this->name;
     switch ($this->type) {
         case 'checkbox':
             if ($this->model instanceof Model) {
                 $this->options['label'] = null;
                 echo Html::activeCheckbox($this->model, $this->attribute, $this->options);
             } else {
                 echo Html::checkbox($this->name, $this->checked, $this->options);
             }
             break;
         case 'radio':
             if ($this->model instanceof Model) {
                 $this->options['label'] = null;
                 echo Html::activeRadio($this->model, $this->attribute, $this->options);
             } else {
                 echo Html::radio($this->name, $this->checked, $this->options);
             }
             break;
         default:
             throw new Exception('Invalid element type');
     }
     $this->register();
 }
开发者ID:softcommerce,项目名称:yii2-ibutton,代码行数:40,代码来源:IButton.php

示例2: renderRadioInput

 private function renderRadioInput()
 {
     $items = [];
     foreach ($this->items as $key => $item) {
         if (!is_array($item)) {
             $options = $this->options;
             $options['value'] = $key;
             $options['label'] = $item;
             $options['labelOptions'] = $this->labelOptions;
         } else {
             $options = ArrayHelper::getValue($item, 'options', []) + $this->options;
             $options['value'] = ArrayHelper::getValue($item, 'value');
             $options['label'] = ArrayHelper::getValue($item, 'label', false);
             $options['labelOptions'] = ArrayHelper::getValue($item, 'labelOptions', []) + $this->labelOptions;
         }
         if ($this->inline) {
             $options['container'] = '';
         }
         $items[] = $this->hasModel() ? Html::activeRadio($this->model, $this->attribute, $options) : Html::radio($this->name, $this->checked, $options);
     }
     $this->containerOptions['class'] = ArrayHelper::getValue($this->containerOptions, 'class', 'form-group');
     print Html::tag('div', implode($this->separator, $items), $this->containerOptions);
 }
开发者ID:hiqdev,项目名称:yii2-bootstrap-switch,代码行数:23,代码来源:BootstrapSwitch.php

示例3: radio

 /**
  * Renders a radio button.
  * This method will generate the "checked" tag attribute according to the model attribute value.
  * @param array $options the tag options in terms of name-value pairs. The following options are specially handled:
  *
  * - uncheck: string, the value associated with the uncheck state of the radio button. If not set,
  *   it will take the default value '0'. This method will render a hidden input so that if the radio button
  *   is not checked and is submitted, the value of this attribute will still be submitted to the server
  *   via the hidden input.
  * - label: string, a label displayed next to the radio button.  It will NOT be HTML-encoded. Therefore you can pass
  *   in HTML code such as an image tag. If this is is coming from end users, you should [[Html::encode()]] it to prevent XSS attacks.
  *   When this option is specified, the radio button will be enclosed by a label tag.
  * - labelOptions: array, the HTML attributes for the label tag. This is only used when the "label" option is specified.
  *
  * The rest of the options will be rendered as the attributes of the resulting tag. The values will
  * be HTML-encoded using [[Html::encode()]]. If a value is null, the corresponding attribute will not be rendered.
  * @param boolean $enclosedByLabel whether to enclose the radio within the label.
  * If true, the method will still use [[template]] to layout the checkbox and the error message
  * except that the radio is enclosed by the label tag.
  * @return static the field object itself
  */
 public function radio($options = [], $enclosedByLabel = true)
 {
     if ($enclosedByLabel) {
         if (!isset($options['label'])) {
             $attribute = Html::getAttributeName($this->attribute);
             $options['label'] = Html::encode($this->model->getAttributeLabel($attribute));
         }
         $this->parts['{input}'] = Html::activeRadio($this->model, $this->attribute, $options);
         $this->parts['{label}'] = '';
     } else {
         $this->parts['{input}'] = Html::activeRadio($this->model, $this->attribute, $options);
     }
     $this->adjustLabelFor($options);
     return $this;
 }
开发者ID:bmsrox,项目名称:yiicomm,代码行数:36,代码来源:ActiveField.php

示例4: radio

 /**
  * Renders a radio button.
  * This method will generate the `checked` tag attribute according to the model attribute value.
  * @param array $options the tag options in terms of name-value pairs. The following options are specially handled:
  *
  * - `uncheck`: string, the value associated with the uncheck state of the radio button. If not set,
  *   it will take the default value `0`. This method will render a hidden input so that if the radio button
  *   is not checked and is submitted, the value of this attribute will still be submitted to the server
  *   via the hidden input. If you do not want any hidden input, you should explicitly set this option as `null`.
  * - `label`: string, a label displayed next to the radio button. It will NOT be HTML-encoded. Therefore you can pass
  *   in HTML code such as an image tag. If this is coming from end users, you should [[Html::encode()|encode]] it to prevent XSS attacks.
  *   When this option is specified, the radio button will be enclosed by a label tag. If you do not want any label, you should
  *   explicitly set this option as `null`.
  * - `labelOptions`: array, the HTML attributes for the label tag. This is only used when the `label` option is specified.
  *
  * The rest of the options will be rendered as the attributes of the resulting tag. The values will
  * be HTML-encoded using [[Html::encode()]]. If a value is `null`, the corresponding attribute will not be rendered.
  *
  * If you set a custom `id` for the input element, you may need to adjust the [[$selectors]] accordingly.
  *
  * @param bool $enclosedByLabel whether to enclose the radio within the label.
  * If `true`, the method will still use [[template]] to layout the radio button and the error message
  * except that the radio is enclosed by the label tag.
  * @return $this the field object itself.
  */
 public function radio($options = [], $enclosedByLabel = true)
 {
     if ($enclosedByLabel) {
         $this->parts['{input}'] = Html::activeRadio($this->model, $this->attribute, $options);
         $this->parts['{label}'] = '';
     } else {
         if (isset($options['label']) && !isset($this->parts['{label}'])) {
             $this->parts['{label}'] = $options['label'];
             if (!empty($options['labelOptions'])) {
                 $this->labelOptions = $options['labelOptions'];
             }
         }
         unset($options['labelOptions']);
         $options['label'] = null;
         $this->parts['{input}'] = Html::activeRadio($this->model, $this->attribute, $options);
     }
     $this->adjustLabelFor($options);
     return $this;
 }
开发者ID:yiisoft,项目名称:yii2,代码行数:44,代码来源:ActiveField.php

示例5: date

    echo Html::img($this->theme->getUrl('images/payment/wxpay.png'));
    ?>
</a>
            </div>
        </div>
        <?php 
}
?>
        <div class="col-sm-4 col-md-3">
            <div class="platform-item platform-submit">
                <a href="#"><?php 
echo Html::img($this->theme->getUrl('images/payment/alipay.png'));
?>
</a>
                <?php 
echo Html::activeRadio($model, 'platform', ['value' => PayOrderForm::PLATFORM_ALIPAY, 'label' => null, 'uncheck' => null]);
?>
            </div>
        </div>
    </div>
    <?php 
echo Html::endForm();
?>
</div>
<?php 
$timeout = date('Y-m-d H:i:s', $order->timeout);
$url = Url::to(['/order/timeout', 'order' => $order->order_sn]);
$js = <<<JS
\$('.platform-submit').click(function () {
    \$(this).find('input[type="radio"]').prop("checked", true);
    \$(this).parents('form').submit();
开发者ID:daixianceng,项目名称:xiaoego.com,代码行数:31,代码来源:pay.php

示例6: renderInput

 public function renderInput()
 {
     return $this->hasModel() ? Html::activeRadio($this->model, $this->attribute, $this->inputOptions) : Html::radio($this->name, $this->checked, $this->inputOptions);
 }
开发者ID:zolotarev,项目名称:yii2-semantic-ui,代码行数:4,代码来源:Radio.php

示例7:

              <td>
                <?php 
    // $form->field($model, "[$index]value")->radio(['value'=>'1','uncheck'=>null])->label(false)
    ?>
                <?php 
    echo Html::activeRadio($model, "[{$index}]value", ['value' => '1', 'uncheck' => null, 'label' => null]);
    ?>
              </td>
              <td>


                <?php 
    //$form->field($model, "[$index]value")->radio(['value'=>'2','uncheck'=>null])->label(false)
    ?>
                <?php 
    echo Html::activeRadio($model, "[{$index}]value", ['value' => '2', 'uncheck' => null, 'label' => null]);
    ?>

              </td>
            </tr>
            <?php 
    echo $form->field($model, "[{$index}]year")->hiddenInput()->label(false);
    ?>
            <?php 
    echo $form->field($model, "[{$index}]kpi_id")->hiddenInput()->label(false);
    ?>
          <?php 
}
?>
          <tr >
开发者ID:phisithos,项目名称:yii2-workshop-co-sapce,代码行数:30,代码来源:_form.php

示例8:

                <h4>在线支付</h4>
                <div class="checked"></div>
                <?php 
echo Html::activeRadio($createOrderForm, 'payment', ['value' => Order::PAYMENT_ONLINE, 'label' => null, 'uncheck' => null]);
?>
            </div>
        </div>
        <div class="col-md-2 col-sm-3 col-xs-5">
            <div class="payment-item<?php 
echo $createOrderForm->payment === Order::PAYMENT_OFFLINE ? ' payment-active' : '';
?>
">
                <h4>货到付款</h4>
                <div class="checked"></div>
                <?php 
echo Html::activeRadio($createOrderForm, 'payment', ['value' => Order::PAYMENT_OFFLINE, 'label' => null, 'uncheck' => null]);
?>
            </div>
        </div>
    </div>
</div>
<div class="place">
    <div>
        <?php 
echo $formOrder->field($createOrderForm, 'remark', ['template' => "{beginWrapper}\n{input}\n{hint}\n{endWrapper}", 'horizontalCssClasses' => ['wrapper' => 'col-md-12', 'hint' => '']])->textarea(['placeholder' => '添加备注,如商品口味、颜色、您的位置等信息。', 'style' => 'resize:vertical;']);
?>
        <?php 
if (Yii::$app->params['enableNewDown'] && $volume >= Yii::$app->params['newDownUpper'] && Yii::$app->user->identity->has_new_down) {
    ?>
        <?php 
    echo $formOrder->field($createOrderForm, 'newDown')->dropDownList(['1' => Yii::$app->params['newDownMsg'], '0' => '不使用优惠']);
开发者ID:daixianceng,项目名称:xiaoego.com,代码行数:31,代码来源:create.php


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