Maldicore / Admin

CakePHP Plugin for automagic admin using Twitter Bootstrap for CakePHP 2.x
52 stars 34 forks source link

Changing the View elements #12

Open witu9217 opened 11 years ago

witu9217 commented 11 years ago

Hi,

I am new to CakePHP so I don't know if this is the correct place to ask this question but i have tried your plugin and it works great. But I am having an issues while creating forms.

I have created DB tables as products and categories. and the categories works great. But now when i see the add products form i want it such that it has a dropdownlist(select) of all the categories inserted. Right now all i get is a input text.

I have the foreign key for the categories in the products table as well.

So how can i acheive that i.e override the view to generate the select box.

//Wilson

yusuf commented 11 years ago

Make sure your table relationships are correctly set in the Models for dropdowns to work. For more info check

http://book.cakephp.org/2.0/en/models/associations-linking-models-together.html

witu9217 commented 11 years ago

Hi yusuf,

Thanx for the reply. But i did everything that is said in the documentation but its still not working.

Here is what i did.

class Product extends AppModel{ public $hasOne = array( 'Category' => array( 'className' => 'Category', 'foreignKey' =>'id', 'dependent' => true ) ); }

class Category extends AppModel{ //put your code here }

I created two models where by product has foreign key for the categories. But still it is populating as a textbox not a selectbox with categories filled into it.

Am i missing somethng?

Please Help !

//Wilson