Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

the field checkBox is not reasonable #114

Open
yii-bot opened this issue Jan 24, 2016 · 1 comment
Open

the field checkBox is not reasonable #114

yii-bot opened this issue Jan 24, 2016 · 1 comment
Labels

Comments

@yii-bot
Copy link

yii-bot commented Jan 24, 2016

This issue has originally been reported by @djfly at yiisoft/yii2#8567.
Moved here by @cebe.


This is a general checkbox
20150527113304

it's not have label at left

if set enclosedByLabel false checkbox is not have name and Not aligned

1432698007

I need the effect like this
1432698007

@Bhoft
Copy link

Bhoft commented Oct 18, 2018

Will this issue be fixed at some time?

I wanted to render a checkbox the same way as a text input field.
So it should contain the form control wrapper div with the label of the checkbox for the required mark.
Followed by the checkbox itself and the hint and errors.

I tried to do the same which is working in yii\widgets\ActiveForm

$model = new yii\base\DynamicModel();
$model->defineAttribute('required_field', $value = null);
$model->addRule(['required_field'], 'required');

$form = yii\widgets\ActiveForm::begin();
echo $form->field($model, 'required_field')->checkbox(['label' => 'Some other options label', 'id'=>uniqid()])->label('external label');

$form = yii\bootstrap\ActiveForm::begin(['layout'=> 'default']);
echo $form->field($model, 'required_field')->checkbox(['label' => 'Some other options label', 'id'=>uniqid()])->label('external label');

The widgets\ActiveForm would look like requested:
image

For bootstrap\ActiveForm the label control is missing:
image

So how can this be done?
It works for other fields (textinput etc.) to call label() but doesn't work for single radio and checkbox.

What I want is render something like this (of course this shows state after an error occurred)
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants