Yii2 REST API remove tag

$xml = new yiiwebXmlResponseFormatter;$xml->rootTag = ‘Response’;        Yii::$app->response->format = ‘custom_xml’;Yii::$app->response->formatters[‘custom_xml’] = $xml;        return [‘customer’ => [‘name’ => ‘John Smith’]];

Yii2 Gridview bulk action using checkbox column. How to properly create checkbox column in gridview for bulk actions

To add a CheckboxColumn to the yiigridGridView, add it to the columns configuration as follows: ‘columns’ => [    // …    [        ‘class’ => ‘yiigridCheckboxColumn’,        // you may configure additional properties here    ],] This is the view: <?=Html::beginForm([‘controller/bulk’],’post’);?><?=Html::dropDownList(‘action’,”,[”=>’Mark selected as: ‘,’c’=>’Confirmed’,’nc’=>’No Confirmed’],[‘class’=>’dropdown’,])?><?=Html::submitButton(‘Send’, [‘class’ => ‘btn btn-info’,]);?><?=GridView::widget([‘dataProvider’ => $dataProvider,’columns’ => [[‘class’ => ‘yiigridCheckboxColumn’],’id’,],]); ?><?= Html::endForm();?> This is the controller: public function actionBulk(){ $action=Yii::$app->request->post(‘action’); $selection=(array)Yii::$app->request->post(‘selection’);//typecasting foreach($selection as $id){ $e=Evento::findOne((int)$id);//make a typecasting //do your stuff $e->save(); } }

Yii 2.0: Displaying, Sorting and Filtering Model Relations on a GridView, Gridview with relationships

One of the things you will find tricky to implement is the the sorting and filtering of a GridView’s column that displays related model data. As you know if you have been playing with Yii2 lately, there is a new proposed way to search for data and is by using objects that extend from the… Continue reading Yii 2.0: Displaying, Sorting and Filtering Model Relations on a GridView, Gridview with relationships