After upgrading form 1.3.7 to 1.3.8 we encountered a problem with
handling custom field names. This commit is supposed to fix custom
name attributes, but when we pass a name that ends in a "[]" it is not
handled correctly.
This example code produces the following:
$this->Form->fields = array( 'Model.field.' );
Note the trailing dot! It is not supposed to be there as it results in
a blackhole.
echo $this->Form->hidden( 'Model.field', array( 'value' => '', 'id' =>
'ModelField', 'secure' => false ) );
foreach ( $items as $key => $value )
{
echo $this->Form->input( 'somefield', array( 'name' => 'data[Model]
[field][]', 'type' => 'checkbox', 'id' => 'ModelField' . $key 'label'
=> $value, 'hiddenField' => false, 'after' => 'some html' ) );
}
A quick fix (though not thoroughly) would be to alter the line 2196 in
the helpers/form.php and change the line from
preg_match_all('/\[(.*?)\]/', $options['name'], $matches);
to:
preg_match_all('/\[(.+?)\]/', $options['name'], $matches);
Is this a bug or a change of behaviour?
--
Our newest site for the community: CakePHP Video Tutorials
http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others
with their CakePHP related questions.
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php