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.