Hi,
I have a widget which fetches data from model.
class SiteTableWidget extends CWidget {
public $siteId;
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 SiteTab view is this
<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>
In another view I need to show this widget, however the content of the widget must be populated based on user input
<?php echo $form->textField($model,'Site_ID', array('onChange'=>'doSomethingToDisplaymyWidget','style'=>'width:100px;', 'autocomplete'=>'off')); ?>
When the user populates the ‘Site_ID’ textField(onChange event), I need to pass the value of the textField to my widget’s $siteId property.
How do I achieve this