Example #1
3
 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();
 }
Example #2
1
    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();
 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);
 }
Example #4
0
 /**
  * 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;
 }
Example #5
0
 /**
  * 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;
 }
Example #6
0
 public function renderInput()
 {
     return $this->hasModel() ? Html::activeRadio($this->model, $this->attribute, $this->inputOptions) : Html::radio($this->name, $this->checked, $this->inputOptions);
 }
              <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 >
Example #8
0
                <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' => '不使用优惠']);