When you update the model, it will automatically have the last selected value. $myModel = new \app\models\myModel; $myModel->attributes = \Yii::$app->request->post('myModel'); ...
You need to set the mapping for sorting. /* Query results array( array( 'id' => 1, 'username' => 'username', 'email' => 'email' ), ... ) */ return new CSqlDataProvider($query, array( 'keyField' => 'id', //required, any field from query results 'totalItemCount'=> $count, 'pagination' => array( 'pageSize' => 10 ), 'sort' =>...
Here a small example. I hope this help you. Widget which show time from server every second. //SiteController public function actionTest() { $this->render('my_view'); //just rendering view } public function actionContent() { $this->widget('time'); //return html of widget. use for ajax } //my_view.php <script src="<?php echo $this->assetsBase ?>/js/jquery-1.10.2.js"></script> <script type="text/javascript"> $(document).ready(function() {...
Yes, it is ok to create a widget for this needs. After done, it is ok to call it from layout. You can even use caching in order not to bother DB too often. http://www.yiiframework.com/wiki/17/how-to-make-use-of-a-fragment-cache/ Finally: I would recommend writing widget and using it with fragmental caching....
You could simply use Html::a() : <?= Html::a('label', ['/controller/action'], ['class'=>'btn btn-primary']) ?> Or create your own version of Button class to handle this. PS: you don't need Url::toRoute...
jquery-ui,yii,jquery-ui-datepicker,zii-widgets,yii-widgets
You can use Html value attribute for this <?php $this->widget('zii.widgets.jui.CJuiDatePicker', array( 'name' => 'publish_date', 'attribute' => 'publish_date', 'model'=>$model, 'options'=> array( 'dateFormat' =>'yy-mm-dd', 'defaultDate' => '2014-3-4', 'altFormat' =>'yy-mm-dd', 'changeMonth' => true, 'changeYear' => true, 'appendText' => 'yyyy-mm-dd', ), 'htmlOptions'=>array('value'=>'2013-4-4') )); ...
There was problem with asset registration. I Kdiff current asset directory with another projects asset directory. And there was files missing I copied them in current project and now its running fine.
gridview,yii2,horizontal-scrolling,yii-widgets
You just need to put a div around it and then set the overflow using CSS. You will need to set the height. overflow: auto; overflow-y: hidden; Height:? ...
redirect to admin action Yii::app()->db->createCommand($query)->execute(); $this->redirect(array('admin')) ...
Select2 widget is an instance of Yii2 Input widget and it renders input for model attribute. It is useful for forms where you create/update your model. So e.g. if it is for actionCreate() you should use your new ActiveRecord model instance for widget 'model' attribute and any attribute name you...
You should try to use a radioButtonList and specify that the column is of a raw type: 'columns'=>array( ... //other columns array( 'name'=> 'test', 'type'=>'raw', 'value' => 'CHtml::radioButtonList("test", $select,array("key" => "value"), array("template" => "{input}", "separator"=>" "))', ), ), ), If you don't know how to use a radioButtonList you should...
You said "previously rendered file" which I interpret that you have the main file already in view in the browser, and then you would like to have new data processed by the controller and passed back the view, for which you would need an ajax call from the main view...
This is not possible without extending and rewriting the grid view widget. Take a look at Kartik GridView. If you take a look at the demo you can see that it has the functionality you need.