本文整理汇总了PHP中yii\helpers\Html::checkbox方法的典型用法代码示例。如果您正苦于以下问题:PHP Html::checkbox方法的具体用法?PHP Html::checkbox怎么用?PHP Html::checkbox使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\helpers\Html
的用法示例。
在下文中一共展示了Html::checkbox方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionForm
public function actionForm()
{
echo Html::beginForm();
echo Html::checkboxList('test', ['value 1' => 'item 1', 'value 2' => 'item 2', 'value 3' => 'item 3'], isset($_POST['test']) ? $_POST['test'] : null, function ($index, $label, $name, $value, $checked) {
return Html::label($label . ' ' . Html::checkbox($name, $value, $checked), null, ['class' => 'inline checkbox']);
});
echo Html::submitButton();
echo Html::endForm();
print_r($_POST);
}
示例2: run
public function run()
{
if (is_null($this->imageOptions)) {
$this->imageOptions = ['class' => 'img-responsive'];
}
$this->imageOptions['id'] = Yii::$app->getSecurity()->generateRandomString(10);
$inputField = Html::getInputId($this->model, $this->attribute);
$class = \yii\helpers\StringHelper::basename(get_class($this->model)) . 'Cutter';
echo Html::beginTag('div', ['class' => 'image-cutter', 'id' => $inputField . '-cutter']);
echo Html::activeFileInput($this->model, $this->attribute);
echo Html::hiddenInput($class . '[' . $this->attribute . ']', $this->model->{$this->attribute});
$previewImage = Html::beginTag('div', ['class' => 'img-container']);
$previewImage .= Html::tag('span', '', ['class' => 'helper']);
$previewImage .= Html::tag('span', Yii::t('sadovojav/cutter/cutter', 'Click to upload image'), ['class' => 'message']);
$previewImage .= Html::img($this->model->{$this->attribute} ? $this->model->{$this->attribute} : null, ['class' => 'preview-image']);
$previewImage .= Html::endTag('div');
echo Html::label($previewImage, Html::getInputId($this->model, $this->attribute), ['class' => 'dropzone']);
echo Html::checkbox($class . '[' . $this->attribute . '-remove]', false, ['label' => Yii::t('sadovojav/cutter/cutter', 'Remove')]);
Modal::begin(['header' => Html::tag('h4', Yii::t('sadovojav/cutter/cutter', 'Cutter'), ['class' => 'modal-title']), 'closeButton' => false, 'footer' => $this->getModalFooter($inputField), 'size' => Modal::SIZE_LARGE]);
echo Html::beginTag('div', ['class' => 'image-container']);
echo Html::img(null, $this->imageOptions);
echo Html::endTag('div');
echo Html::tag('br');
echo Html::beginTag('div', ['class' => 'row']);
echo Html::beginTag('div', ['class' => 'col-md-2']);
echo Html::label(Yii::t('sadovojav/cutter/cutter', 'Aspect ratio'), $inputField . '-aspectRatio');
echo Html::textInput($class . '[' . $this->attribute . '-aspectRatio]', isset($this->cropperOptions['aspectRatio']) ? $this->cropperOptions['aspectRatio'] : 0, ['id' => $inputField . '-aspectRatio', 'class' => 'form-control']);
echo Html::endTag('div');
echo Html::beginTag('div', ['class' => 'col-md-2']);
echo Html::label(Yii::t('sadovojav/cutter/cutter', 'Angle'), $inputField . '-dataRotate');
echo Html::textInput($class . '[' . $this->attribute . '-cropping][dataRotate]', '', ['id' => $inputField . '-dataRotate', 'class' => 'form-control']);
echo Html::endTag('div');
echo Html::beginTag('div', ['class' => 'col-md-2']);
echo Html::label(Yii::t('sadovojav/cutter/cutter', 'Position') . ' (x)', $inputField . '-dataX');
echo Html::textInput($class . '[' . $this->attribute . '-cropping][dataX]', '', ['id' => $inputField . '-dataX', 'class' => 'form-control']);
echo Html::endTag('div');
echo Html::beginTag('div', ['class' => 'col-md-2']);
echo Html::label(Yii::t('sadovojav/cutter/cutter', 'Position') . ' (y)', $inputField . '-dataY');
echo Html::textInput($class . '[' . $this->attribute . '-cropping][dataY]', '', ['id' => $inputField . '-dataY', 'class' => 'form-control']);
echo Html::endTag('div');
echo Html::beginTag('div', ['class' => 'col-md-2']);
echo Html::label(Yii::t('sadovojav/cutter/cutter', 'Width'), $inputField . '-dataWidth');
echo Html::textInput($class . '[' . $this->attribute . '-cropping][dataWidth]', '', ['id' => $inputField . '-dataWidth', 'class' => 'form-control']);
echo Html::endTag('div');
echo Html::beginTag('div', ['class' => 'col-md-2']);
echo Html::label(Yii::t('sadovojav/cutter/cutter', 'Height'), $inputField . '-dataHeight');
echo Html::textInput($class . '[' . $this->attribute . '-cropping][dataHeight]', '', ['id' => $inputField . '-dataHeight', 'class' => 'form-control']);
echo Html::endTag('div');
echo Html::endTag('div');
Modal::end();
echo Html::endTag('div');
$options = ['inputField' => $inputField, 'useWindowHeight' => $this->useWindowHeight, 'cropperOptions' => $this->cropperOptions];
$options = Json::encode($options);
$this->view->registerJs('jQuery("#' . $inputField . '").cutter(' . $options . ');');
}
示例3: buildHtmlTreeInput
public static function buildHtmlTreeInput($model, $attribute, $data)
{
$value = $model->{$attribute};
$lines = [];
if (is_array($data) && count($data) > 0) {
$lines[] = '<ul>';
foreach ($data as $k => $v) {
$lines[] = '<li>';
$lines[] = '<div class="checkbox icheck">';
$lines[] = Html::checkbox(Html::getInputName($model, $attribute) . '[' . $k . ']', isset($value[$k]), ['value' => $k, 'label' => '<span>' . (Yii::t('b/radiata/user', $attribute . '_' . $k) != $attribute . '_' . $k ? Yii::t('b/radiata/user', $attribute . '_' . $k) : $k) . '</span>']);
$lines[] = '</div>';
if (is_array($v)) {
$lines[] = self::buildHtmlTreeInput($model, $attribute, $v);
}
$lines[] = '</li>';
}
$lines[] = '</ul>';
}
return join("\n", $lines);
}
示例4: actionIndex
public function actionIndex()
{
$dataAry = $columns = [];
$auth = Yii::$app->authManager;
//只挑選本店家權限
$_cnt = 1;
foreach ($auth->getPermissions() as $key => $value) {
$_tmp = array('id' => $_cnt, 'label' => $value->description);
$_tmp["assign_1"] = Html::checkbox("assign_item", true, ["disabled" => true]);
// $_tmp["assign_1"] = Html::checkbox("assign_item", $auth->hasChild($auth->getRole("1"), $value), ["class" => "role-assign",
// "data-name" => $value->name,
// "data-role" => 1]);
$_tmp["assign_2"] = Html::checkbox("assign_item", $auth->hasChild($auth->getRole("2"), $value), ["class" => "role-assign", "data-name" => $value->name, "data-role" => 2]);
$_tmp["assign_3"] = Html::checkbox("assign_item", $auth->hasChild($auth->getRole("3"), $value), ["class" => "role-assign", "data-name" => $value->name, "data-role" => 3]);
$dataAry[] = $_tmp;
$_cnt++;
}
$dataProvider = new ArrayDataProvider(['allModels' => $dataAry, 'pagination' => false]);
$columns[] = array("header" => "功能", 'format' => 'raw', 'options' => ["style" => "width:20%;"], "value" => function ($data) {
return $data["label"];
});
foreach (Yii::$app->params["adminRoleType"] as $key => $value) {
$columns[] = array("header" => $value, 'format' => 'raw', "value" => function ($data) use($key) {
return $data["assign_" . $key];
});
}
return $this->render('index', ['dataProvider' => $dataProvider, "columns" => $columns]);
}
示例5: run
/**
*
*/
public function run()
{
$view = $this->getView();
$this->registerScript($view);
if ($this->hasModel()) {
if ($this->label) {
$label = $this->label;
} else {
$label = Html::encode($this->model->getAttributeLabel(Html::getAttributeName($this->attribute)));
}
$tag = ArrayHelper::remove($this->textOptions, 'tag', 'span');
$text = Html::tag($tag, $label, $this->textOptions);
$this->options['label'] = $text;
$checkbox = Html::activeCheckbox($this->model, $this->attribute, $this->options);
} else {
$checkbox = Html::checkbox($this->name, $this->value, $this->options);
if ($this->label) {
$tag = ArrayHelper::remove($this->textOptions, 'tag', 'span');
$text = Html::tag($tag, $this->label, $this->textOptions);
$checkbox = Html::tag('label', $checkbox . ' ' . $text, $this->labelOptions);
}
}
$input = Html::tag('div', $checkbox, $this->containerOptions);
echo strtr($this->template, ['{input}' => $input]);
}
示例6: variant
private function variant($item)
{
$return = [];
$checked = $this->model->checkedId($item->id);
$return[] = Html::checkbox('variant', $checked, ['id' => 'filtervariant' . $item->id, 'data-id' => $item->id]);
$return[] = ' ';
$return[] = Html::label($item->value, 'filtervariant' . $item->id);
return Html::tag('li', implode('', $return));
}
示例7: renderCheckboxInput
private function renderCheckboxInput()
{
if ($this->hasModel()) {
$input = Html::activeCheckbox($this->model, $this->attribute, $this->options);
} else {
$input = Html::checkbox($this->name, $this->checked, $this->options);
}
print $this->inlineLabel ? $input : Html::tag('div', $input);
}
示例8: renderDataCellContent
/**
* @inheritdoc
*/
protected function renderDataCellContent($model, $key, $index)
{
$this->options['value'] = $model->name;
$role = \Yii::$app->request->get('role');
if (in_array($model->name, $this->children[$role])) {
return Html::checkbox($this->name, true, $this->options);
} else {
return Html::checkbox($this->name, false, $this->options);
}
}
示例9: run
/**
* Runs the widget
*
* @return string
*/
public function run()
{
$this->registerAssets();
if ($this->hasModel()) {
echo Html::activeCheckbox($this->model, $this->attribute, $this->options);
} else {
$checked = ArrayHelper::remove($this->options, 'checked', false);
echo Html::checkbox($this->name, $checked, $this->options);
}
}
示例10: get_content
protected function get_content($data, $isActiveForm = FALSE)
{
$res = array();
// Ссылка добавления настройка для секции
$res[] = Html::a('<i class="fa fa-cog"></i> add', [$this->add_set_link], ['class' => 'add_settings_in_section']);
foreach ($data as $item) {
$res[] = '<div class="row">' . '<div class="form-group">' . Html::label($item['key'], $item['key'], ['class' => 'col-sm-2 control-label']) . '<div class="col-sm-3">' . $this->set_input_type($item['type'], $item['key'], $item['value']) . Html::hiddenInput($item['key'] . '[type]', $item['type']) . '</div>' . '</div>' . '<div class="col-sm-4">' . Html::tag('span', $item['description']) . '</div>' . Html::label('active', 'active', ['class' => 'col-sm-2 control-label']) . '<div class="col-sm-1">' . Html::checkbox($item['key'] . '[active]', $this->has_checked($this->has_checked($item['active'])), ['data-atr' => 'icheck', 'class' => 'flat-red']) . '</div>';
}
return $res;
}
示例11: renderDataCellContent
/**
* @inheritdoc
*/
protected function renderDataCellContent($model, $key, $index)
{
$this->options['value'] = $model->_id;
$this->options['id'] = 'selection_' . uniqid();
if (in_array($model->_id, $this->itemPermissions)) {
return null;
} else {
return Html::checkbox($this->name, false, $this->options);
}
}
示例12: variant
private function variant($item, $checked)
{
$return = [];
if ($checked) {
$checked = in_array($item->id, $checked);
}
$return[] = Html::checkbox('variant', $checked, ['autocomplete' => 'off', 'id' => 'fieldvariant' . $item->id, 'data-id' => $item->id]);
$return[] = ' ';
$return[] = Html::label($item->value, 'fieldvariant' . $item->id);
return Html::tag('li', implode('', $return));
}
示例13: run
public function run()
{
if (is_null($this->imageOptions)) {
$this->imageOptions = ['class' => 'img-responsive'];
}
$this->imageOptions['id'] = Yii::$app->getSecurity()->generateRandomString(10);
$inputField = Html::getInputId($this->model, $this->attribute);
echo Html::beginTag('div', ['id' => $inputField . '-cutter']);
echo Html::activeFileInput($this->model, $this->attribute, ['class' => 'hide']);
echo Html::beginTag('div', ['class' => 'preview-pane', 'style' => $this->model->{$this->attribute} ? 'display:block' : 'display:none']);
echo Html::beginTag('div', ['class' => 'preview-container']);
echo Html::img($this->previewImgSrc ? $this->previewImgSrc : $this->model->{$this->attribute}, ['class' => 'preview-image ' . $this->previewImgClass]);
echo Html::endTag('div');
echo Html::endTag('div');
echo Html::checkbox($this->attribute . '-remove', false, ['label' => Yii::t('davfervaz/cutter', 'Remove photo')]);
Modal::begin(['header' => Html::tag('h4', Yii::t('davfervaz/cutter', 'Select the cut area')), 'closeButton' => [], 'footer' => $this->getModalFooter($inputField), 'size' => Modal::SIZE_LARGE]);
echo Html::beginTag('div', ['class' => 'image-container']);
echo Html::img(null, $this->imageOptions);
echo Html::endTag('div');
echo Html::tag('br');
echo Html::beginTag('div', ['class' => 'row']);
echo Html::beginTag('div', ['class' => 'col-md-2']);
echo Html::label(Yii::t('davfervaz/cutter', 'ASPECT_RATIO'), $inputField . '-aspectRatio');
echo Html::textInput($this->attribute . '-aspectRatio', isset($this->cropperOptions['aspectRatio']) ? $this->cropperOptions['aspectRatio'] : 0, ['id' => $inputField . '-aspectRatio', 'class' => 'form-control']);
echo Html::endTag('div');
echo Html::beginTag('div', ['class' => 'col-md-2']);
echo Html::label(Yii::t('davfervaz/cutter', 'ANGLE'), $inputField . '-dataRotate');
echo Html::textInput($this->attribute . '-cropping[dataRotate]', '', ['id' => $inputField . '-dataRotate', 'class' => 'form-control']);
echo Html::endTag('div');
echo Html::beginTag('div', ['class' => 'col-md-2']);
echo Html::label(Yii::t('davfervaz/cutter', 'POSITION') . ' (X)', $inputField . '-dataX');
echo Html::textInput($this->attribute . '-cropping[dataX]', '', ['id' => $inputField . '-dataX', 'class' => 'form-control']);
echo Html::endTag('div');
echo Html::beginTag('div', ['class' => 'col-md-2']);
echo Html::label(Yii::t('davfervaz/cutter', 'POSITION') . ' (Y)', $inputField . '-dataY');
echo Html::textInput($this->attribute . '-cropping[dataY]', '', ['id' => $inputField . '-dataY', 'class' => 'form-control']);
echo Html::endTag('div');
echo Html::beginTag('div', ['class' => 'col-md-2']);
echo Html::label(Yii::t('davfervaz/cutter', 'WIDTH'), $inputField . '-dataWidth');
echo Html::textInput($this->attribute . '-cropping[dataWidth]', '', ['id' => $inputField . '-dataWidth', 'class' => 'form-control']);
echo Html::endTag('div');
echo Html::beginTag('div', ['class' => 'col-md-2']);
echo Html::label(Yii::t('davfervaz/cutter', 'HEIGHT'), $inputField . '-dataHeight');
echo Html::textInput($this->attribute . '-cropping[dataHeight]', '', ['id' => $inputField . '-dataHeight', 'class' => 'form-control']);
echo Html::endTag('div');
echo Html::endTag('div');
Modal::end();
echo Html::endTag('div');
$view = $this->getView();
CutterAsset::register($view);
$options = ['inputField' => $inputField, 'useWindowHeight' => $this->useWindowHeight, 'cropperOptions' => $this->cropperOptions];
$options = Json::encode($options);
$view->registerJs('jQuery("#' . $inputField . '").cutter(' . $options . ');');
}
示例14: run
/**
* @inheritdoc
*/
public function run()
{
if ($this->hasModel()) {
$input = Html::activeCheckbox($this->model, $this->attribute, $this->options);
} else {
$input = Html::checkbox($this->name, $this->checked, $this->options);
}
echo $this->inlineLabel ? $input : Html::tag('div', $input);
$this->selector = "#{$this->options['id']}";
$this->registerClientScript();
}
示例15: run
/**
* @inheritdoc
*/
public function run()
{
$option = array_merge(['label' => false, 'class' => 'make-switch'], $this->options);
if ($this->hasModel()) {
$input = Html::activeCheckbox($this->model, $this->attribute, $option);
} else {
$input = Html::checkbox($this->name, $this->checked, $option);
}
echo $this->inlineLabel ? $input : Html::tag('div', $input);
$this->selector = "#{$option['id']}";
$this->registerClientScript();
}