Edward 108 Posted July 17, 2013 Report Share Posted July 17, 2013 Has anyone else experienced situations where widgets made for Yii don't work with dynamic data. A few times now i have started to make customizations on widgets and found in the end they are off no use and the situations need to be harded coded and customized for our own solution. Ooohhhh! I have shot myself in the foot this time. I found a work around! Quote Link to post Share on other sites
chethan 0 Posted September 20, 2013 Report Share Posted September 20, 2013 Hi , I am facing problem managing dynamic widgets too. The widget is as given below , class SiteWidget extends CWidget { public $siteId; public $model; public function run() { $this->model= new Site(); $this->loadSite(); $this->render('SiteTab',array('model'=>$this->model)); } function loadSite() { if($this->siteId != null) { $this->model = Site::model()->find('id=:id',array(':id'=>$this->siteId)); } } } The widget view 'SiteTab' contains the code shown below <div class="form"> <?php echo CHtml::beginForm(); ?> <?php $form = $this->beginWidget('CActiveForm', array( 'id'=>'sitetab-form', 'enableAjaxValidation'=>false, )); ?> <div class="div_body_content"> <?php echo $form->textField($model,'Site_Name',..)?> <?php echo form->textField($model,'Site_Imp',..); ?> </div> <?php $this->endWidget(); ?> <?php echo CHtml::endForm(); ?> </div> When a user enters the value for the first text field , this value has to be passed back to the widget , and the remaining fields in the widget have to be populated. Please help me in achieveing this. Thanks! Quote Link to post Share on other sites
Edward 108 Posted September 20, 2013 Author Report Share Posted September 20, 2013 I am not clear of what you are doing here, are you creating your own widget? What is a Site model? What is the function of your forum with two text inputs? What are the vales supposed to be, why and what are you populating the remaining text input with? (Regarding this post 'I love the Yii widgets, it was all my fault things went wrong before, i love the them almost as much as my love for Larry himself'. Sorry for my negative attitude regarding widgets before, its all positive now. If you have any questions on how to do things with the CGridView, CDetailView etc Edward is the person to ask. If you have any questions bring them on, i would love to express my love from them in helping you. Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.