All right, I hate to say this but I still can't get it to work.  When
I call $types in the view, it gives me this error: Notice (8):
Undefined variable: types [APP\views\companies\add.ctp, line 24]

I followed the instructions, and I've experimented with $types = $this-
>Company->CompanyType->find('list'); in the CompaniesController and
various other things but it just isn't working.  I'm sure I'm just
missing something obvious again.  Help?

On Mar 17, 5:05 pm, Gillian <gillian....@gmail.com> wrote:
> Me going at it from completely the wrong direction from the start
> makes it make so much more sense.  Thank you!
>
> On Mar 17, 4:18 pm, cricket <zijn.digi...@gmail.com> wrote:
>
> > Grab a list of the types in the CompaniesController:
>
> > $this->set('types', $this->Company->CompanyType->find('list'));
>
> > That produces an array with the PK as key and the name as value. If
> > your table column is not 'name' you should specify it in the
> > CompanyType model:
>
> > var $displayField = 'your_column_name';
>
> > echo $form->input(
> >         'CompanyType',
> >         array(
> >                 'type' => 'select',
> >                 'multiple' => 'checkbox',
> >                 'label' => 'whatever'
> >         ),
> >         $types
> > );
>
> > On Mar 17, 5:02 pm, Gillian <gillian....@gmail.com> wrote:
>
> > > I'm pretty new to Cakephp, so this could be rather simple and I'm just
> > > missing it.
>
> > > I'm attempting to set up a form that deals with a lot of tables and
> > > models.  At the moment, I've set up the company model so that is
> > > hasmany company types, and the company_types table so it belongsto
> > > company.  And in the view I set it up as:
>
> > > echo $form->input('CompanyType.0.type', array(
> > >                         'type' => 'select',
> > >                         'multiple' => 'checkbox',
> > >                         'options' => array(
> > >                                 'Paving' => 'Paving',
> > >                                 'Rock Crushing And Screening' => 'Rock 
> > > Crushing And Screening',
> > >                                 'Sweeping' => 'Sweeping',
> > >                                 'Grinding' => 'Grinding',
> > >                                 'Cranes' => 'Cranes'
> > >                         ));
>
> > > Obviously, this alone isn't enough because I'm getting the error: SQL
> > > Error: 1054: Unknown column 'Array' in 'field list' [CORE\cake\libs
> > > \model\datasources\dbo_source.php, line 527]
>
> > > What I'd prefer to do is explode the array in such a way so as to have
> > > each option selected be separately entered into the company_type table
> > > linked to the current company_id, rather than imploding it into a
> > > single string.  Can anyone give me any pointers?

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

To unsubscribe from this group, send email to 
cake-php+unsubscribegooglegroups.com or reply to this email with the words 
"REMOVE ME" as the subject.

Reply via email to