In the Controller, calls to your models should go in your controllers. On Wed, Mar 5, 2008 at 2:34 AM, George C <[EMAIL PROTECTED]> wrote: > > > > On Jan 25, 8:32 am, MonkeyGirl <[EMAIL PROTECTED]> wrote: > > > How would you get the enum values from the model or controller? > > > > By far the easiest way is to go > tohttp://cakeforge.org/snippet/detail.php?type=snippet&id=112 > > and copy and paste the code that's there into app_model.php, then you > > can just use lines like the following in your code: > > > > $types = $this->Album->getEnumValues('type'); > > > > In this example, 'type' is the name of the enum column, Album is the > > model it's in, and 'types' is the variable that will automatically be > > picked up by this line in the view (assuming you're using Cake 1.2 > > with its form helper): > > > > echo $form->input('type'); > > > > This will give you a dropdown, just like the one you get for foreign > > keys. > > > > Hope that helps, > > Zoe. > > Looks simple enough, but I'm very new to the whole Model-View- > Controller paradigm, so I can't quite make sense of this. > > Adding the first part of that code into the app_model.php file is > straightforward enough, and I only need the "function add()" section > if I intend to use this functionality with Bake (right?) which I > currently don't. > > So, would I want to say in some view: > $types = $this->Album->getEnumValues('type'); > echo $form->input('type'); > $labels = $this->Album->getEnumValues('label') > echo $form->input('label') > > Or that's what I'd think to do at first glance, but it doesn't seem to > work - $this seems to point to the current "view" object and not the > "Album" object, which I suppose makes sense. But then it's not clear > to me where the "$types = $this->Album->getEnumValues('type');" line > ought to go, if not in the view page. Thanks in advance for any > clarification you can send my way! > > > >
--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---