1.You can cover the state array to be an array of key=value
OR
2.Use the id to fetch the state name before saving.

On Mon, Aug 22, 2011 at 6:15 PM, arron <[email protected]> wrote:

> that maybe true but i cant get that to work using the simple mail and
> wizard components. I dont necessarily need it to save to the database
> but just be able to send the name for the state as a email instead of
> a number
>
> On Aug 17, 2:08 am, WebbedIT <[email protected]> wrote:
> > I know Irun the risk of preaching to the converted here, but if you
> > have a table of states with IDs and Names then you should only ever
> > save the ID as you never want to save the name more than once.  What
> > if you need to change the name of a state (mis-spelling) you then have
> > to run multiple updates to change mulitple occurences rather than
> > changing just the one record in the lookup table.
> >
> > It takes no time at all to then reference the state's name once you
> > have the ID as Cake will automatically include any belongsTo
> > associations when running finds on the model and therefore include the
> > state name in $findResult['State']['name']. Maybe you need to go back
> > to whoever is saying you need to store the name and convince them
> > otherwise.
> >
> > On Aug 16, 10:04 pm, arron <[email protected]> wrote:
> >
> >
> >
> >
> >
> >
> >
> > > I have a dependent drop down
> > > using jquery works fine
> >
> > > I found out today that i need to populate the name of the state in
> > > another table instead of the id.
> >
> > > in my controller i use a simple find to populate the select box.
> >
> > > //controller
> >
> > > $states= $this->State->find('list',array
> > > ('fields'=>array('State.id','State.state')));
> >
> > >         $this->set(compact('states'));
> >
> > > in my view when someone picks the state it populates the city
> > > then saves it to my users table state_id
> >
> > > //view
> >
> > >                 <?php echo
> $this->Form->select('state_id',array($states),'state',array('id'=>'states')
> ,false);
> >
> > >                 ?><br /><br /><?php echo $this->Form-
> >
> > > >select('city_id',array('name'),'null',array('id'=>'cites'),false);?>
> >
> > > the problem i am facing is how can i save the state name instead of
> > > the value ?
> >
> > > if i change my controller to this:
> >
> > > //controller
> >
> > > $states= $this->State->find('list',array
> > > ('fields'=>array('State.state','State.state')));
> >
> > >         $this->set(compact('states'));
> >
> > > It will save the form as i needed it, but my find will not work
> > > because there is no id for the where clause.
> >
> > > i just need to save my option instead of my id and cant figure it out
>
> --
> Our newest site for the community: CakePHP Video Tutorials
> http://tv.cakephp.org
> Check out the new CakePHP Questions site http://ask.cakephp.org and help
> others with their CakePHP related questions.
>
>
> To unsubscribe from this group, send email to
> [email protected] For more options, visit this group
> at http://groups.google.com/group/cake-php
>



-- 
Regards,
Zaky Katalan-Ezra
QA Administrator
www.IGeneriX.com
Sites.IGeneriX.com
054-7762312

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to