Issue
I'm trying to create a radio button using a loop
<?= $this->Form->create($account) ?>
<?php foreach($gametitles as $gametitle): ?>
<?= $this->Form->radio(
'gametitle_id',
[
['value' => $gametitle->id,'text'=>'','hiddenField' => false],
]
);
?>
<?php endforeach; ?>
<?= $this->Form->button(__('Submit')) ?>
<?= $this->Form->end() ?>
I have added 'hiddenField' => false
, but in DOM I'm seeing still hidden field displaying. In output I'm getting always empty value if I select without last radio button.
[
'gametitle_id' => '',
]
If I use name as an array gametitle_id[]
I am getting an array
'gametitle_id' => [
(int) 0 => '',
(int) 1 => '',
(int) 2 => '4',
(int) 3 => '',
(int) 4 => '',
],
How I will get only one value that has selected in radio button ? I have used 'hiddenField' => false
, still why hidden field is displaying ?
Solution
You have set 'hiddenField' => false
in options ! You have to set it with name.
echo $this->Form->radio(
'favorite_color',
[
['value' => 'r', 'text' => 'Red', 'style' => 'color:red;']
],
['hiddenField' => false]
)
Answered By - Alimon Karim
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.