Form : Checkbox fields formatting strange field names. #5966

3 views
Skip to first unread message

francky06l

unread,
Nov 8, 2007, 9:27:21 AM11/8/07
to CakePHP Bleeding Edge
It seems the changes in form have a problem with hidden fields (other
than id). Actually the hidden field is usually correct but the fields
after hidden get their names inserted with the hidden field name.
This obvious with the check boxes since, by default, it generates and
hidden field.

The code :
<?php echo $form->create('User');?>
<fieldset>
<legend><?php echo sprintf(__('Add %s', true), __('User', true));?
></legend>
<?php
echo $form->input('check', array('type' => 'checkbox',
'value' => 1));
echo $form->input('role_id');
echo $form->input('username');
...

will produce
<form id="UserAddForm" method="post" action="/cake12/tstacl/users/
add"><input type="hidden" name="_method" value="POST" /> <fieldset>
<legend>Add User</legend>
<div class="input"><input type="hidden" name="data[User][check]
[check]" value="0" id="UserCheck_" /><input type="checkbox"
name="data[User][check][check]" value="1" id="UserCheck" /><label
for="User">Check</label></div><div class="input"><label
for="UserRoleId">Role</label><select name="data[User][check][role_id]"
id="UserRoleId">
<option value="1">administrator</option>
<option value="9">Manager</option>
</select></div><div class="input"><label for="UserUsername">Username</
label><input name="data[User][check][username]" type="text"
maxlength="64" value="" id="UserUsername" /></div><div
class="input"><label for="UserPassword">Password</label><input
type="password" name="data[User][check][password]" value=""
id="UserPassword" /></div> </fieldset>

Have a look to the names of the fields, they all get "[check]"
inserted.
If I move the username field before the checkbox, the name will be
correct.
I have also set the field check to be hidden ( 'type' => 'hidden') and
this produce the same error.
It's correct if I have no field (other than "id") hidden

The last version working from the branch (for me) was 5950

Reply all
Reply to author
Forward
0 new messages