digging through the DOM further, I notice that the autocomplete form
element creates a div after itself with
id="PracticeItemName_autoComplete". It has the same id for each
autocomplete form (which would explain why only one works), so I guess
my question comes down to:

How can I specify the name of this "helper div" when invoking the
$ajax->autoComplete method?

On 16 Apr, 19:41, Johnny Ferguson <hyperfle...@gmail.com> wrote:
> practice_sessions_controller.php:http://pastebin.com/XHw37WS0
>
> practice_sessions/add.ctp:http://pastebin.com/Z5fGgfxV
>
> practice_items_controller.php: (autoCompleteName)http://pastebin.com/SLN72D4T
>
> On 16 Apr, 19:38, Johnny Ferguson <hyperfle...@gmail.com> wrote:
>
>
>
> > So I've looked further into this, and I tried the obvious solution
>
> > It seems that the items in $this->data are assigned a number from the
> > name field of the input element.
>
> > name="data[PracticeInstance][0][tempostart]"
>
> > means the form will feed the data back as $this-
>
> > >data['PracticeInstance']['0']['tempostart']
>
> > So when I created my ajax autoComplete field I tried:
> > $ajax->autoComplete('PracticeItem.name', '/practice_items/
> > autoCompleteName', array('name' => 'data[PracticeItem][0][name]'));
>
> > For some reason the second autocomplete field won't autocomplete. When
> > I submit the form though, my $this->data looks like:
>
> > Array
> > (
> >     [PracticeItem] => Array
> >         (
> >             [name] => TEST
> >         )
>
> >     [PracticeInstance] => Array
> >         (
> >             [0] => Array
> >                 (
> >                     [timeminutes] => 20
> >                     [tempostart] => 120
> >                     [tempofinish] => 130
> >                 )
>
> >             [1] => Array
> >                 (
> >                     [timeminutes] => 40
> >                     [tempostart] => 100
> >                     [tempofinish] => 110
> >                 )
>
> >         )
>
> > )
>
> > As you can see, the PracticeItem element has the first autoComplete
> > field's data missing, and it acts as though the only bit that
> > qualifies as [PracticeItem][name] is the last entry in the form.
>
> > On 16 Apr, 15:20, Johnny Ferguson <hyperfle...@gmail.com> wrote:
>
> > > Hi, I've noticed that CakePHP has an autoComplete helper, but I'm
> > > having trouble figuring out how to make it work for my 
> > > application:http://book.cakephp.org/view/632/autoComplete
>
> > > I have 3 controllers:
> > > PracticeItems
> > > PracticeInstances
> > > PracticeSessions
>
> > > A PracticeSession will have 1 or more PracticeInstances
> > > A PracticeInstance has 1 PracticeItem
>
> > > I'm working on the add method for PracticeSessions.
>
> > > This form should start with 4 fields:
> > > PracticeItem.0.name (this one is autocomplete)
> > > PracticeInstance.0.timeminutes
> > > PracticeInstance.0.tempostart
> > > PracticeInstance.0.tempofinish
>
> > > It shouldn't be hard to add a button that will generate another 4
> > > fields with the value 0 incremented accordingly. My problem is that
> > > autoComplete() accepts its argument as "ModelName.FieldName". I can't
> > > use the notation with a number in the middle.
>
> > > This means when I get back $this->data I have something like:
>
> > > Array
> > > (
> > >     [PracticeItem] => Array
> > >         (
> > >             [name] => Another Test Item
> > >         )
>
> > >     [PracticeInstance] => Array
> > >         (
> > >             [0] => Array
> > >                 (
> > >                     [timeminutes] => 20
> > >                     [tempostart] => 100
> > >                     [tempofinish] => 120
> > >                 )
>
> > >         )
>
> > > )
>
> > > But what I want is
>
> > > Array
> > > (
> > >     [PracticeItem] => Array
> > >         (
> > >             [0] => Array
> > >                 (
> > >                     [name] => Another Test Item
> > >                 )
> > >         )
>
> > >     [PracticeInstance] => Array
> > >         (
> > >             [0] => Array
> > >                 (
> > >                     [timeminutes] => 20
> > >                     [tempostart] => 100
> > >                     [tempofinish] => 120
> > >                 )
>
> > >         )
>
> > > )
>
> > > This would be trivial for a single entry, but as I'll be adding more
> > > form fields on the fly, I'm not sure how it will work if I can't say
> > > $ajax->autoComplete('PracticeItem.n.name', '/practice_items/
> > > autoComplete')
>
> > > I'm thinking I could add an extra parameter to the autoComplete
> > > function, but since it's built in, I'm not sure how to go about this.
>
> > > Check out the new CakePHP Questions sitehttp://cakeqs.organdhelpothers 
> > > with their CakePHP related questions.
>
> > > You received this message because you are subscribed to the Google Groups 
> > > "CakePHP" group.
> > > To post to this group, send email to cake-php@googlegroups.com
> > > To unsubscribe from this group, send email to
> > > cake-php+unsubscr...@googlegroups.com For more options, visit this group 
> > > athttp://groups.google.com/group/cake-php?hl=en
>
> > Check out the new CakePHP Questions sitehttp://cakeqs.organdhelp others 
> > with their CakePHP related questions.
>
> > You received this message because you are subscribed to the Google Groups 
> > "CakePHP" group.
> > To post to this group, send email to cake-php@googlegroups.com
> > To unsubscribe from this group, send email to
> > cake-php+unsubscr...@googlegroups.com For more options, visit this group 
> > athttp://groups.google.com/group/cake-php?hl=en
>
> Check out the new CakePHP Questions sitehttp://cakeqs.organd help others with 
> their CakePHP related questions.
>
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group 
> athttp://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to