public function actionAutocomplete() { $term = trim($_GET['term']); if ($term != '') { // Note: Users::usersAutoComplete is the function you created in Step 2 $cur = Currecies::AutoComplete($term); echo \yii\helpers\Json::encode($cur); Yii::$app->end(); } }
<div class="form"> <?php $form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array('id' => 'currates-form', 'enableAjaxValidation' => false)); ?> <?php echo $form->errorSummary($model); ?> <?php echo $form->dropDownListRow($model, 'currency_id', CHtml::listData(Currecies::model()->findAll(), 'id', 'name')); ?> <br /> <?php echo $form->labelEx($model, 'value'); ?> <?php echo $form->textField($model, 'value', array('size' => 7, 'maxlength' => 7)); ?> <?php echo $form->error($model, 'value'); ?> <div class="form-actions"> <?php $this->widget('bootstrap.widgets.TbButton', array('buttonType' => 'submit', 'type' => 'primary', 'label' => $model->isNewRecord ? Yii::t('app', "Create") : Yii::t('app', "Save"))); ?> </div>
<?php $this->breadcrumbs = array('Currates' => array('index'), 'Manage'); $this->menu = array(array('label' => Yii::t('app', 'Create Currency Rate'), 'url' => array('create'))); ?> <?php $this->beginWidget('MiniForm', array('header' => Yii::t('app', "Manage Currencies Rates"))); ?> <?php // this is the date picker $dateisOn = $this->widget('zii.widgets.jui.CJuiDatePicker', array('name' => 'Currates[from]', 'language' => substr(Yii::app()->language, 0, 2), 'value' => $model->from, 'options' => array('showAnim' => 'fold', 'dateFormat' => Yii::app()->locale->getDateFormat('short'), 'changeMonth' => 'true', 'changeYear' => 'true', 'constrainInput' => 'false'), 'htmlOptions' => array('placeholder' => Yii::t('app', 'From Date'))), true) . $this->widget('zii.widgets.jui.CJuiDatePicker', array('name' => 'Currates[to]', 'language' => substr(Yii::app()->language, 0, 2), 'value' => $model->to, 'options' => array('showAnim' => 'fold', 'dateFormat' => Yii::app()->locale->getDateFormat('short'), 'changeMonth' => 'true', 'changeYear' => 'true', 'constrainInput' => 'false'), 'htmlOptions' => array('placeholder' => Yii::t('app', 'To Date'))), true); ?> <?php $this->widget('EExcelView', array('id' => 'currates-grid', 'dataProvider' => $model->search(), 'template' => '{items}{pager}', 'filter' => $model, 'ajaxUpdate' => true, 'ajaxType' => 'POST', 'afterAjaxUpdate' => "function() {\n\t\t\t\t\t\tjQuery('#Currates_from').datepicker(jQuery.extend({showMonthAfterYear:false}, jQuery.datepicker.regional['" . substr(Yii::app()->language, 0, 2) . "'], {'showAnim':'fold','dateFormat':'" . Yii::app()->locale->getDateFormat('short') . "','changeMonth':'true','showButtonPanel':'true','changeYear':'true','constrainInput':'false'}));\n\t\t\t\t\t\tjQuery('#Currates_to').datepicker(jQuery.extend({showMonthAfterYear:false}, jQuery.datepicker.regional['" . substr(Yii::app()->language, 0, 2) . "'], {'showAnim':'fold','dateFormat':'" . Yii::app()->locale->getDateFormat('short') . "','changeMonth':'true','showButtonPanel':'true','changeYear':'true','constrainInput':'false'}));\n }", 'columns' => array(array('name' => 'currency_id', 'filter' => CHtml::listData(Currecies::model()->findAll(), 'id', 'name'), 'value' => 'isset($data->Currency)?$data->Currency->name:0'), array('name' => 'date', 'filter' => $dateisOn, 'value' => '$data->date'), 'value'))); $this->endWidget();