form-> giriş için bir seçenek ('birden çok' => 'kutusu') nasıl ayarlanacağı

1 Cevap php

i plan to set a checkbox with selected option in my form. but i am unable to show my checkbox content in the form, i cant see any value instead of just a box for me to select.

how to show value while i using checkbox? i able to show my value while i using select. this is in a HABTM model. any hints?

İşte benim seçim kodudur.

input('User',array('label' => 'Select Related Potential', 'multiple'=>'checkbox', //'options' => $users,
'legend'=>$users,
//'value'=>$users,
//'id'=>$ownUserId,
'default'=>$ownUserId, 'style'=>'width:200px;height:100px', 'selected' => $ownUserId, )); ?>

1 Cevap

This ilgili olabilir:

Sen default, bir onay kutusunu kontrol etmek için kullanamazsınız - yerine {giriş seçeneğini sizin görünümünde, $form->data sizin denetleyicisi $this->data değerini ayarlayın, ya da ayarlayabilirsiniz [(3)]} ile true.


Örneğin:

// in Controller
$this->data['Model']['field'] = true;

Bu alan bir alan için bir kontrol onay kutusu neden olur değerini true, olması neden olur.

Veya:

$form->input('Model.field', array('checked' => true));

Her zaman onay kutusunu denetler.

Veya:

$form->input('Model.field', array(
    'checked' => ($this->data['Model']['field'] == 'xxx')
));

Dinamik $this->data['Model']['field'] 'xxx' olup olmadığı dayalı onay kutusunu ayarlar.


Maalesef, tamamen soruyu yanlış.

Eğer find your users via list ? The options array needs to be in a particular format, a normal find() bunu yapmayacağım mı.