I removed the model name (Search) from the field(s) and the result was the
same ... minus [Search] in the array (obviously).
All the field names are now uniform with both the search view and the ajax
view.

The region view (returned) via ajax simply echoes the region field and that
is all.
I didn't see the need for a form create or end.

If I follow you correctly on the HTML thing, when the page initially loads
the HTML is as you would expect "<select name="region" id="SearchRegion">"
or I am not following you on that one?

At first I was inclined to think that it had something to do with the Ajax,
but now I just confused 8-) Even though the (ajax) region is submitting with
the rest of the form ($this->params) it's still being treated as it's own
element which makes sense because it started off as it's own element and was
introduced to the form after the fact. Does that make any sense?

The reason I made the comment in my earlier post about going about this
differently is because if I was able to pass back an array of new regions
and reload the existing region field with that array instead of passing back
a whole new form element (region), I'm thinking none of this would be an
issue.

I guess I need to play around some more because there must be a way to do
that. Cake has been quite the learning experience 8-)

- Ed

On Wed, Jun 16, 2010 at 4:15 AM, John Andersen <[email protected]>wrote:

> Thanks Ed :)
>
> Ok, off the top of my head - I see that every other form field you
> specify as:
> [code]
> $form->input('fieldname', ...);
> [/code]
> Note, you use only the fieldname without the modelname.
> But for the region, you attach Search as the modelname! Have you tried
> to remove it?
>
> Does the region view (the one which is returned using Ajax) only
> contain the form field without having a form create and end?
> What does the HTML look like, when the region is first populated after
> you choose a country? Is it defined as:
> [code]
> ... name="data[Search][region]" ...
> [/code]
>
> You have to make it look like the other fieldnames! (I assume they
> differ!)
> Enjoy,
>    John
>
> On Jun 16, 10:58 am, Ed Propsner <[email protected]> wrote:
> > Sorry about that John, I'm not quite with it today ... i'm a bit under
> the
> > weather.
> > This is the part of the view for the search.
> >
> > $form->input('country', array(
> > 'label' => '',
> > 'type' => 'select',
> > 'empty' => '-- Select --',
> > 'selected' => $this->Session->read('Auth.User.country')
> > )
> >   )
> >
> > $ajax->observeField('SearchCountry', array(
> >    'url' => array(
> >   'action' => 'getRegion'
> >   ),
> >    'frequency' => 0.1,
> >    'update' => 'displayRegion'
> >    )
> >  )
> >
> > Upon 'onchange' event the selected country id is passed to the controller
> > where it queries a new list of regions for that country.
> >
> > The controller passes the array of regions to a separate view (perhaps
> could
> > have done this differently?) where a new select element is populated with
> > the array of regions.
> >
> > $form->input('Search.region', array(
> > 'label' => '',
> > 'type' => 'select',
> > 'options' => $region
> > )
> >  );
> >
> > The 'region' select element in the search form sits inside a div and is
> > overwritten by the above element.
> > The new select element is getting passed into the search form as
> $this->data
> > which makes sense but it's also remaining
> > that way when the form submits.
> >
> > So now with using GET the form submits as
> >
> >             [minAge] => 31
> >             [maxAge] => 41
> >             [country] => Chile
> >             [data] => Array
> >                 (
> >                     [Search] => Array
> >                         (
> >                             [region] => Libertador General Bernardo
> O'Higgins
> >                         )
> >
> >                 )
> >
> > I straightened out the array once the form is received by the
> > controller but the form has already submitted at that point and it
> > leaves my url
> >
> > looking like "  country=Chile&data[Search][region]= " on the results
> > page. I still utilize the data from url on the results page so
> >
> > data[Search][region]=  is throwing it off especially if the user sorts
> > the data and the url switches back to "region=" as it was originally
> > intended.
> >
> > I feel like this didn't help any 8-), let me know if I'm still being too
> vague.
> >
> > - Ed
> [snip]
>
> 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 [email protected]
> To unsubscribe from this group, send email to
> [email protected]<cake-php%[email protected]>For
>  more options, visit this group at
> http://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 [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to