Re: Format Array

2010-06-16 Thread John Andersen
Please provide more details for us to consider! For a starter I think
the following would be necessary:
The code that returns data for your ajax call.
The code of the view in which the dropdown data is to be used.

Enjoy,
   John


On Jun 16, 2:55 am, Ed Propsner crotchf...@gmail.com wrote:
 My last post was a bit misleading ... The way I should have stated it is
 that using array_merge() and unset()
 I was able to structure the array the way that I want it in the controller
 action for the search results so it's not throwing
 an error, but it is still showing in the url as 
 country=Chiledata[Search][region]= . The results page has a custom sort
 so when the data is sorted the url changes back to  country=Chileregion=
 . I had to alter the controller, view, and a few elements
 to account for the difference and to keep it from giving an error.

 What I would like to do is have $this-params array arrive at the controller
 already formatted the way I want instead of me
 having to manipulate the array once it get's there.
[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 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


Re: Format Array

2010-06-16 Thread Ed Propsner
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=Chiledata[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

On Wed, Jun 16, 2010 at 3:03 AM, John Andersen j.andersen...@gmail.comwrote:

 Please provide more details for us to consider! For a starter I think
 the following would be necessary:
 The code that returns data for your ajax call.
 The code of the view in which the dropdown data is to be used.

 Enjoy,
   John


 On Jun 16, 2:55 am, Ed Propsner crotchf...@gmail.com wrote:
  My last post was a bit misleading ... The way I should have stated it is
  that using array_merge() and unset()
  I was able to structure the array the way that I want it in the
 controller
  action for the search results so it's not throwing
  an error, but it is still showing in the url as 
  country=Chiledata[Search][region]= . The results page has a custom sort
  so when the data is sorted the url changes back to 
 country=Chileregion=
  . I had to alter the controller, view, and a few elements
  to account for the difference and to keep it from giving an error.
 
  What I would like to do is have $this-params array arrive at the
 controller
  already formatted the way I want instead of me
  having to manipulate the array once it get's there.
 [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 cake-php@googlegroups.com
 To unsubscribe from this group, send email to
 cake-php+unsubscr...@googlegroups.comcake-php%2bunsubscr...@googlegroups.comFor
  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 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


Re: Format Array

2010-06-16 Thread John Andersen
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 crotchf...@gmail.com 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=Chiledata[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 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


Re: Format Array

2010-06-16 Thread Ed Propsner
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 j.andersen...@gmail.comwrote:

 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 crotchf...@gmail.com 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=Chiledata[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 cake-php@googlegroups.com
 To unsubscribe from this group, send email to
 cake-php+unsubscr...@googlegroups.comcake-php%2bunsubscr...@googlegroups.comFor
  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 cake-php@googlegroups.com
To 

Re: Format Array

2010-06-16 Thread John Andersen
Good luck Ed, hope someone else can give you some better advice! I
unfortunately haven't played around with Ajax as much, so can't shed
any light on the issue!
Enjoy,
   John

On Jun 16, 11:59 am, Ed Propsner crotchf...@gmail.com wrote:
 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
[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 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


Re: Format Array

2010-06-16 Thread Ed Propsner
No prob, thanks a bunch John! I'll keep tinkering and I'm sure I'll come up
with something. The worst that can happen is I learn something new 8-).

On Wed, Jun 16, 2010 at 5:27 AM, John Andersen j.andersen...@gmail.comwrote:

 Good luck Ed, hope someone else can give you some better advice! I
 unfortunately haven't played around with Ajax as much, so can't shed
 any light on the issue!
 Enjoy,
John

 On Jun 16, 11:59 am, Ed Propsner crotchf...@gmail.com wrote:
  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
 [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 cake-php@googlegroups.com
 To unsubscribe from this group, send email to
 cake-php+unsubscr...@googlegroups.comcake-php%2bunsubscr...@googlegroups.comFor
  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 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


Format Array

2010-06-15 Thread Ed Propsner
I have a dropdown in one of my searches that is populated via ajax.

When the form submits (GET) my params end up looking something like:

[code]

[minAge] = 31
[maxAge] = 41
[country] = Chile
[data] = Array
(
[Search] = Array
(
[region] = Libertador General Bernardo O'Higgins
)

)


[/code]

If there a way for me to format the array so it's in sync with the rest of
the form?

eg.

[minAge] = 31
[maxAge] = 41
[country] = Chile
[data] = Array
[region] = Libertador General Bernardo O'Higgins


Nothing I tried has worked.

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


Re: Format Array

2010-06-15 Thread Ed Propsner
My last post was a bit misleading ... The way I should have stated it is
that using array_merge() and unset()
I was able to structure the array the way that I want it in the controller
action for the search results so it's not throwing
an error, but it is still showing in the url as 
country=Chiledata[Search][region]= . The results page has a custom sort
so when the data is sorted the url changes back to  country=Chileregion=
. I had to alter the controller, view, and a few elements
to account for the difference and to keep it from giving an error.

What I would like to do is have $this-params array arrive at the controller
already formatted the way I want instead of me
having to manipulate the array once it get's there.

On Tue, Jun 15, 2010 at 5:47 PM, Ed Propsner crotchf...@gmail.com wrote:

 I have a dropdown in one of my searches that is populated via ajax.

 When the form submits (GET) my params end up looking something like:

 [code]

 [minAge] = 31
 [maxAge] = 41
 [country] = Chile
 [data] = Array
 (
 [Search] = Array
 (
 [region] = Libertador General Bernardo O'Higgins
 )

 )


 [/code]

 If there a way for me to format the array so it's in sync with the rest of
 the form?

 eg.

 [minAge] = 31
 [maxAge] = 41
 [country] = Chile
 [data] = Array
 [region] = Libertador General Bernardo O'Higgins


 Nothing I tried has worked.






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