本文整理汇总了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();
}
示例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);
}
示例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;
}
示例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;
}
示例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();
示例6: renderInput
public function renderInput()
{
return $this->hasModel() ? Html::activeRadio($this->model, $this->attribute, $this->inputOptions) : Html::radio($this->name, $this->checked, $this->inputOptions);
}
示例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 >
示例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' => '不使用优惠']);