Use Country. Cake's Inflector can handle it.

As for the rest, you should be doing it in the controller. Also, you
should use find('list') for a select tag.

If your model is properly associated with Country, this should be
simple. Here's how I do it for an Event model:

class Event extends AppModel
{
        public $belongsTo = array('Country');
...
}

EventsController:

public function add()
{
        if (!empty($this->data))
        {
                if ($this->Event->save($this->data))
                {
                        $this->flash(
                                'Event created',
                                array(
                                        'action' => 'index',
                                        'admin' => 0
                                )
                        );
                }
                else
                {
                        $this->flash('Event not created',null,'flash_error');
                }
        }
        $this->set('countries', $this->Event->Country->find('list'));
}

form:

<?= $form->input('Event.country_id', array('label' => 'Country')) ?>

Note that you don't even require a Country model if your countries
table has both an id & name field. Cake will sort it out.


On Tue, Sep 15, 2009 at 8:03 PM, www.landed.at <calvincr...@gmail.com> wrote:
>
> I need to do something like the following
>
> $this->loadModel('Countrie');
> $countries = $this->Countrie->find('all');
> echo $form->select('country',$countries)
>
> error is
>
> Call to undefined method View::loadModel
>
> Also have the inflection issue as country is not plurally similar to
> countries so I canot find the inflections file to edit this. But I
> think that seems like a separate issue.
>
> thanks
> >
>

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to