Checked Option
Closed this issue · 8 comments
Hello Dear ,
Thanks for your work ,
i need to know if i have old values and i need to make checked attribute for some input,
how i can make some of radio checked ? .
Regards
hey, I wish if you shard some code and where are you using this
in a resource or a page
by default the "edit" should work and fill the values from your DB
but giving the following example you can set the values using formatStateUsing
like this
Matrix::make('question')
->asCheckbox()
->formatStateUsing(fn()=>[
'sat'=>['one'=>true],
'sun'=>['two'=>true],
'mon'=>['three'=>true],
])
->columnData([
'one'=>'One Item',
'two'=>'Two Item',
'three'=>'Three Item',
])
->rowData([
'sat' => 'Saturday',
'sun' => 'Sunday',
'mon' => 'Monday',
]),
if you have values without keys:
->formatStateUsing(fn()=>[
[0=>true],
[1=>true],
[2=>true],
])
->columnData([
'one',
'two',
'three',
])
->rowData([
'sat',
'sun',
'mon',
])
and you can always dd()
the form and see how the array is structured
i will try with your feed back ,
and i will feed you back ,
Thanks Again <3
in this case you should try use key values to store the data
the:
'Question One',
'Question Five',
is the labels not the values
and it all depend how you store the data
Thanks Dear,
i will try and feed you back ,
i like your code
Regards