Re: Forms with multiple tables
Hi Travis, Please read http://book.cakephp.org/view/438/displayField Regards, Hendry On Sun, Jul 5, 2009 at 7:36 AM, Travis wrote: > Thanks, That worked. > > I have one more question, is there a way I can tell it what field to > put in the select, right now it is using the field "name" and I would > like it to use the field "common_name" since as you can figure out > common name is what we call it, as apposed to the government assigned > name. > > Travis --~--~-~--~~~---~--~~ 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: Forms with multiple tables
Thanks, That worked. I have one more question, is there a way I can tell it what field to put in the select, right now it is using the field "name" and I would like it to use the field "common_name" since as you can figure out common name is what we call it, as apposed to the government assigned name. Travis On Jul 3, 10:13 pm, "Paul" wrote: > Sorry last post sent in error > > So you have your view with some fields in it, including your forign key - > here assuming farm_id > > views/fields/add.ctp > > create('Field')?> > input('name')?> > input('another')?> > input('yet_another')?> > input('farm_id')?> > end('Submit')?> > > And in your controller action add ( as long as you have your association set > up correctly which we'll assume you do as you mention it) > > controllers/fields_controller.php > > function add(){ > ~ > $this->set('farms', $this->Field->Farm->find('list')); > > } > > This will set values to your view that the form helper will automatically > pick up and set as the values of your Field.farm_id input - which will > become a select. > > > > -Original Message- > From: cake-php@googlegroups.com [mailto:cake-...@googlegroups.com] On Behalf > > Of Travis > Sent: Saturday, 4 July 2009 3:34 a.m. > To: CakePHP > Subject: Forms with multiple tables > > I am new to cakePHP and am in the process of learning to use it. > > I am wondering how I can have a form element populated with elements > from a different table than the model, for example > > I am wanting to write a farm manager using cakePHP as the framework, > if I have fields that belong to farms, when you create a new field I > want to be able to select from a list of farms, and have it link > (insert farm's id as a foreign key), I have currently setup my > belongsto relationship so I can view but I cannot add. > > my original thought was to create a $options array and just loop > through the table, but I cannot do that if I do not have access to the > farms table. > > Help! > > __ Information from ESET NOD32 Antivirus, version of virus signature > database 4214 (20090703) __ > > The message was checked by ESET NOD32 Antivirus. > > http://www.eset.com > > __ Information from ESET NOD32 Antivirus, version of virus signature > database 4215 (20090704) __ > > The message was checked by ESET NOD32 Antivirus. > > http://www.eset.com --~--~-~--~~~---~--~~ 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: Forms with multiple tables
Sorry last post sent in error So you have your view with some fields in it, including your forign key - here assuming farm_id views/fields/add.ctp create('Field')?> input('name')?> input('another')?> input('yet_another')?> input('farm_id')?> end('Submit')?> And in your controller action add ( as long as you have your association set up correctly which we'll assume you do as you mention it) controllers/fields_controller.php function add(){ ~ $this->set('farms', $this->Field->Farm->find('list')); } This will set values to your view that the form helper will automatically pick up and set as the values of your Field.farm_id input - which will become a select. -Original Message- From: cake-php@googlegroups.com [mailto:cake-...@googlegroups.com] On Behalf Of Travis Sent: Saturday, 4 July 2009 3:34 a.m. To: CakePHP Subject: Forms with multiple tables I am new to cakePHP and am in the process of learning to use it. I am wondering how I can have a form element populated with elements from a different table than the model, for example I am wanting to write a farm manager using cakePHP as the framework, if I have fields that belong to farms, when you create a new field I want to be able to select from a list of farms, and have it link (insert farm's id as a foreign key), I have currently setup my belongsto relationship so I can view but I cannot add. my original thought was to create a $options array and just loop through the table, but I cannot do that if I do not have access to the farms table. Help! __ Information from ESET NOD32 Antivirus, version of virus signature database 4214 (20090703) __ The message was checked by ESET NOD32 Antivirus. http://www.eset.com __ Information from ESET NOD32 Antivirus, version of virus signature database 4215 (20090704) __ The message was checked by ESET NOD32 Antivirus. http://www.eset.com --~--~-~--~~~---~--~~ 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: Forms with multiple tables
So you have your view views/fields/add.ctp create('Field')?> create('Field')?> -Original Message- From: cake-php@googlegroups.com [mailto:cake-...@googlegroups.com] On Behalf Of Travis Sent: Saturday, 4 July 2009 3:34 a.m. To: CakePHP Subject: Forms with multiple tables I am new to cakePHP and am in the process of learning to use it. I am wondering how I can have a form element populated with elements from a different table than the model, for example I am wanting to write a farm manager using cakePHP as the framework, if I have fields that belong to farms, when you create a new field I want to be able to select from a list of farms, and have it link (insert farm's id as a foreign key), I have currently setup my belongsto relationship so I can view but I cannot add. my original thought was to create a $options array and just loop through the table, but I cannot do that if I do not have access to the farms table. Help! __ Information from ESET NOD32 Antivirus, version of virus signature database 4214 (20090703) __ The message was checked by ESET NOD32 Antivirus. http://www.eset.com __ Information from ESET NOD32 Antivirus, version of virus signature database 4215 (20090704) __ The message was checked by ESET NOD32 Antivirus. http://www.eset.com --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Forms with multiple tables
I am new to cakePHP and am in the process of learning to use it. I am wondering how I can have a form element populated with elements from a different table than the model, for example I am wanting to write a farm manager using cakePHP as the framework, if I have fields that belong to farms, when you create a new field I want to be able to select from a list of farms, and have it link (insert farm's id as a foreign key), I have currently setup my belongsto relationship so I can view but I cannot add. my original thought was to create a $options array and just loop through the table, but I cannot do that if I do not have access to the farms table. 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---