V
V
VitaliyKaliuzhyn2017-02-07 17:13:37
Yii
VitaliyKaliuzhyn, 2017-02-07 17:13:37

Customizing radioList() yii2?

In the standard output of radioList()

<?=$form->field($model,'created_at')->radioList(['Radio 1', 'Radio 2', 'Radio 3'],['labelOptions'=>['class'=>'mt-radio'],'name'=>"test"]); ?>

at the output I get
<div id="users-created_at" name="test" labeloptions="{&quot;class&quot;:&quot;mt-radio&quot;}"><label><input type="radio" name="test" value="0"> Radio 1</label>
<label><input type="radio" name="test" value="1"> Radio 2</label>
<label><input type="radio" name="test" value="2"> Radio 3</label></div>

redefining the output template like this
Html::beginTag('label', $labelOptions) .
                Html::Tag('input','',$options).
                Html::beginTag('span') .
                Html::endTag('span') .
                Html::endTag('label');

at the output instead of three radioButton I get one
<label class="mt-radio"><input type="radio" name="test"]"><span></span></label>

How can I get everything that I set as attributes in radioList () at the output

Answer the question

In order to leave comments, you need to log in

4 answer(s)
D
Dmitry, 2017-02-07
@slo_nik

Good afternoon.
You are doing everything wrong.
The documentation for radioList has a link to activeRadioList . In the options parameter, you can call a function in which you override the appearance of radioList
ps Approximately like this:

'item' => function($index,$label,$name,$checked,$value){
                                        return Html::radio($name,
                                                           $checked,
                                                           [
                                                               'label' => $label,
                                                               'value' => $value,
                                                               'labelOptions' => ['class' => 'niceInput']
                                                           ]);

                                    }

A
Alisa Danilova, 2017-09-19
@kolesov_prod

robots.txt with content:

User-agent: *
Disallow: /*demo

Place in demo folder

V
Vladimir Mukovoz, 2017-09-19
@castomi

At the root of each folder, throw robots.txt that prohibits indexing. Is that what you asked? It just seems obvious to me.

S
Sergey, 2017-09-19
@prasx

\||||/

Disallow: /*demo

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question