You never want to access the Model from the view so your controller should call the method in the model to grab the list, then pass it to the view using $this->set. Then you can do your foreach in the view and build your output
On Tue, Dec 8, 2009 at 6:27 AM, Dr. Loboto <[email protected]> wrote: > Model should only retrieve data you need. Not by find('list') in you > case. Then you foreach this data in your view and form proper params > for $form->input(). > > On Dec 8, 1:17 am, ianmcn <[email protected]> wrote: > > I'm trying to use the form helper to render a bunch of radio inputs. > > By default, as you will know, the options are taken from a simple > > key=>value array retrieved from the database using $this->Model->find > > ("list"). However, I want the value labels to be styled showing a > > heading, paragraph text and a small image, all of this data is stored > > in fields in the table but not found using the list. > > > > I have it working at the moment, but not in a very elegant way. I have > > a function in the model which builds the array with appropriate html > > tags but without the images (because obviously I can't access the > > image helper in the model), then in the view I have a foreach loop > > which appends the image to each item in the array (images are named > > with corresponding primary key). This works, but doesn't seem very MVC > > to me, can anyone suggest a better way I could achieve the same thing? > > > > Thanks > > > > Ian McNaught > > 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 [email protected] > To unsubscribe from this group, send email to > [email protected]<cake-php%[email protected]>For > 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 [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
