Yii Framework Forum: Dependant Drop Down Help - Yii Framework Forum

Jump to content

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

Dependant Drop Down Help Rate Topic: -----

#1 User is offline   salman 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 44
  • Joined: 30-August 10

Posted 07 August 2012 - 12:46 PM

I have completed my project, only thing left is Dependant Drop Down which i am unable to understand here, i just need to solve in next couple of hours

I appreciate if someone make its its code here is schema

CREATE TABLE IF NOT EXISTS `tbl_category` (
  `id` int(10) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;


and

CREATE TABLE IF NOT EXISTS `tbl_subcategory` (
  `id` int(10) NOT NULL AUTO_INCREMENT,
  `cid` int(11) NOT NULL,
  `name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
  PRIMARY KEY (`id`),
FOREIGN KEY (cid) REFERENCES tbl_category(id) ON UPDATE CASCADE ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;



and here are relations of subcategory

	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'linkdirectories' => array(self::HAS_MANY, 'Linkdirectory', 'scid'),
			'c' => array(self::BELONGS_TO, 'Category', 'cid'),
		);
	}

Good Programming is 99% Sweet and 1% Coffee
0

#2 User is offline   riemann 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 23
  • Joined: 31-August 11
  • Location:Algeria

Posted 07 August 2012 - 12:57 PM

Hi,
Sorry to can't solve the probleme about relation but there are a solution if you havent' time to investigate

<?php echo $form->dropDownList($model,'cid',CHtml::listData(Category::model()->findAll(),'id','name')); ?>


Hope this code can help you.
Good luck.
0

#3 User is offline   bennouna 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,123
  • Joined: 05-January 12
  • Location:Morocco

Posted 07 August 2012 - 01:46 PM

Quote

only thing left is Dependant Drop Down which i am unable to understand here

Have you tried anything? Have you seen this wiki?
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