Yii Framework Forum: Dropdownlist - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Dropdownlist Rate Topic: -----

#1 User is offline   kayo 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 11
  • Joined: 15-March 13
  • Location:Curitiba, Brazil

Posted 15 March 2013 - 03:42 PM

Hi,
I'm new to Yii, I'm trying to create a DropDownList between two Tables: Category and Product.

Category Table:

create table category (
id integer not null primary key auto_increment,
name varchar(256) not null
)
engine = InnoDB;


Product Table:

create table product (
id integer not null primary key auto_increment,
name varchar(256) not null
)
engine = InnoDB;


Category and Product Assignment:

create table category_product_assignment (
category_id int(11) not null,
product_id int(11) not null,
primary key (category_id, product_id) 
) 
engine = InnoDB;

alter table category_product_assignment
add constraint FK_category_product 
foreign key (category_id)
references category(id)
on delete cascade
on update restrict;

alter table category_product_assignment
add constraint FK_product_category
foreign key (product_id)
references product(id)
on delete cascade
on update restrict;


My question is:
How can I insert a DropDownList into the views/product/_form.php that have an array of Categories?
Thanks in advance for your time
0

#2 User is offline   rei 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 329
  • Joined: 10-November 10

Posted 16 March 2013 - 06:50 AM

Something like this, perhaps?

You can replace Account model with your Category model.
Fipick - Find and pick recommendations
0

#3 User is offline   kayo 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 11
  • Joined: 15-March 13
  • Location:Curitiba, Brazil

Posted 19 March 2013 - 02:52 PM

that's it! thanks!
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users