Yii Framework Forum: Dependent Dropdown Within Cwidget - Yii Framework Forum

Jump to content

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

Dependent Dropdown Within Cwidget Rate Topic: ***** 1 Votes

#1 User is offline   AhmetS 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 13
  • Joined: 01-May 13

Posted 08 May 2013 - 08:16 AM

I am trying to create a widget with a dependent dropdown box.

Following tutorial: http://www.yiiframework.com/wiki/24, I am faced with the following problem with the ajax part:

echo CHtml::dropDownList('metal_id', 'id', $metals, array(
    'ajax' => array(
        'type' => 'POST', //request type
        'url' => $this->getController()->createUrl('currentController/dynamicProducts'),
        'update' => '#product_id',
    )
));


using CController is not possible, because I am inside a CWidget, not CController.

I can however use something like:

'url' => $this->getController()->createUrl('currentController/dynamicProducts')


However it still does not solve my problem because the URL created will not refer to the WidgetController.

Question 1: How can I get my ajax to call a method from within my CWidget?
Question 2: I am using a widget because I want this form to be available on several pages. Should I be creating a partial view instead??? If so, how do I pass the data required from another controller into the partial view?
Question 3: Should I be creating an actual controller inside the Controllers folder which echos out the dynamicProducts options?


Workaround Solution: I have got this working by creating separate AjaxController.php within the controllers folder which simply echos the product option values, however this in my opinion is a very messy solution.
0

#2 User is offline   AhmetS 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 13
  • Joined: 01-May 13

Posted 10 May 2013 - 04:55 AM

Anybody have any ideas???
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