for a valid address, etc. but adding this other data doesn't fit with
validation. You could put that functionality in beforeSave(). Or write
a behavior to do it. Better yet, you could create a component that
modifies the controller's $data before it's ever passed to the model.
So, you could do something like:
if ($this->Model->validates())
{
$this->GoogleMapAPI->setAddressCoords();
if ($this->Model->save($this->data))
{
...
... where the component's setAddressCoords() would modify the
controller's $data array.
On Wed, Sep 2, 2009 at 9:02 PM, Kyle Decot<kdecot9@gmail.com> wrote:
>
> My reasoning behind me wanting to do it this way is because I have an
> address,city, region, and country fields on my form, and then in my
> beforeValidate(), I am taking those values and using the Google Map
> API and if it's a real address w/ a accuracy level of 8, then I add in
> the lat, lng, and accuracy level variables to my $this->data. So there
> no way to pass those values back to the view?
>
> On Sep 2, 8:50 pm, brian <bally.z...@gmail.com> wrote:
>> beforeValidate() is a model method. Model has it's own $data. But the
>> $this->data you're thinking of (I think) is handed from the controller
>> to the view. You would have to modify the controller's array, IOW.
>> Perhaps you'd be better off adding those 2 values in
>> Model::beforeSave().
>>
>>
>>
>> On Wed, Sep 2, 2009 at 3:15 PM, Kyle Decot<kdec...@gmail.com> wrote:
>>
>> > I am having a little bit of trouble w/ my $this->data. When someone
>> > submits the form, in my beforeValidate() method, I create two new
>> > variables inside of $this->data ($this->data['Model']['lat'] && $this-
>> >>data['Model']['lng'])...I I then want to pass those back to the view
>> > if the validation of the rest of the form fails but when I pr($this-
>> >>data) in my view, lat and lng are not there. How do I make sure those
>> > values are passed back? Thank you for any help.
> >
>
--~--~---------~--~----~------------~-------~--~----~
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+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---
No comments:
Post a Comment