#1704 √ wont-fix
merovinq

Form Helper Keying not working as expected in some situations

Reported by merovinq | May 12th, 2011 @ 11:41 AM | in 1.3.13 (closed)

What I did

Installed a fresh cake installation to make sure it was behaving this way out of the box. Created a Testers Controller, Tester Model, and test action and view.

Setup the test action as so.

function test(){
                if(isset($this->data)){
                        debug($this->data);
                }
        }

Setup the view as stated in the following post -> http://nuts-and-bolts-of-cakephp.com/2009/03/26/saveall-with-multip...

<?php
    echo $form->create();
 
    echo $form->input('1.User.name');
    echo $form->input('1.Comment.0.comment');
 
    echo $form->input('2.User.name');
    echo $form->input('2.Comment.0.comment');
 
    echo $form->end('Save');
 
?>

Submitted the form.

What happened

The input tag name attribute made by the Form Helper had an extra set of keys in the beginning of the data array to be submitted, looking like so ->


When submitting the form the posted data array posted to the action also had an extra set of keys looking like so ->

caketest/controllers/testers_controller.php (line 8)

Array
(

[1] => Array
    (
        [1] => Array
            (
                [User] => Array
                    (
                        [name] => 
                    )

                [Comment] => Array
                    (
                        [0] => Array
                            (
                                [comment] => 
                            )

                    )

            )

    )

[2] => Array
    (
        [2] => Array
            (
                [User] => Array
                    (
                        [name] => 
                    )

                [Comment] => Array
                    (
                        [0] => Array
                            (
                                [comment] => 
                            )

                    )

            )

    )

)

What I expected to happen

I expected the input to look like so ->


I expected the data array to look like so ->

Array
(

[1] => Array
    (
        [User] => Array
            (
                [name] => bob
            )

        [Comment] => Array
            (
                [0] => Array
                    (
                        [comment] => nice guy
                    )

            )

    )

[2] => Array
    (
        [User] => Array
            (
                [name] => dave
            )

        [Comment] => Array
            (
                [0] => Array
                    (
                        [comment] => pain in the ass
                    )

            )

    )

)

Example can be found here -> http://208.64.37.102/caketest/testers/test

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Source available from github

Repository is at http://github.com/cakephp/cakephp

Creating a bug report

When creating a bug report, please include as much relevant information as possible. Please include code to reproduce the issue. Or even better, make a unit test. Either change an existing test or add a new test to show that the expected behavior is not occuring.

Referenced by