You need the corresponding belongsTo for your hasOne, and then you should get the related data as $this->Ingredient->IngredientType.
On Dec 21, 3:55 pm, "[email protected]" <[email protected]> wrote: > I am having an issue trying to figure out how to get data from a model > that has a relationship with the current model. > > I have an ingredients table and ingredient_types table > I have an Ingredients model and an IngredientTypes model > > I have an IngredientsController and an IngredientTypesController > > In the IngredientsController I have defined var $hasOne = > 'IngredientType'; > > I believe this is because an ingredient has one type. > > If that is correct what I want to know is how to get the > ingredient_types in the add view for the ingredient. I cant seem to > suss out what it would be. I have looked at the docs but they only > seem to show how to define the relationship. > > So in app\views\ingredients\add.ctp I want to add this: > > echo $form->select('ingredient_type_id', $options = array()); > > But I dont know how to get the data for ingredient types in there. Any > help is much appreciated > > Thanks. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
