yii2

How to hide detail view labels on yii2

人盡茶涼 提交于 2019-12-11 15:35:13
问题 I want to hide labels for the detail view <?= DetailView::widget([ 'model' => $model, //To hide labels 'label' => ['hidden' => true], 'attributes' => [ 'visits' ], ]) ?> On the above snipet of code, there is 'label' => ['hidden' => true], is there but it is not a method which is existing. I want to know is there a method to hide labels Something which is equivalent to that. 回答1: If you want to hide label column in GridView you must modify its enter link description heretemplate. For example:

How to disable /override dependencies in Yii2

喜夏-厌秋 提交于 2019-12-11 15:30:14
问题 Problem : The 'kartik-v\yii2-dialog' which is used by 'kartik-v\tree-manager' overrides Sweetalert dialog/message box. How does one disable the treeview-manager's dependency 'kartik-v\yii2-dialog' in order to use SweetAlerts? Tried : 'assetManager' => ['bundles' => [ 'kartik\dialog\DialogAsset' => ['js' => [],], ... , Sweetalert starts working in grids and confirm events, but then treemanager no longer works (Uncaught ReferenceError: KrajeeDialog is not defined) In Pictures: Have: Want: Any

Share Assets between frontend and backend in Yii2 Advanced template

天大地大妈咪最大 提交于 2019-12-11 14:39:31
问题 i've been trying to load a simple CSS (custom.css) from the frontend and backend of my project and I't has been a real pain. The css is located in: frontend/views/web/css/custom.css It loads without problems in the frontend... this is the AppAsset file located in the frontend: <?php namespace frontend\assets; use yii\web\AssetBundle; /** * Main frontend application asset bundle. */ class AppAsset extends AssetBundle { public $basePath = '@webroot'; public $baseUrl = '@web'; public $css = [

Yii2 - Validating nested objects

杀马特。学长 韩版系。学妹 提交于 2019-12-11 14:18:21
问题 Here's a question about a topic that Ive been thinking about for a while. In Yii2, it is recommended generally to create Form Models for your requests. Rules are added to those models to validate the input. An example is the EntryForm in the Yii2 guide <?php namespace app\models; use Yii; use yii\base\Model; class EntryForm extends Model { public $name; public $email; public function rules() { return [ [['name', 'email'], 'required'], ['email', 'email'], ]; } } My problem is, when we have

How to pass subquery as table name to another query in yii2

北城以北 提交于 2019-12-11 14:18:08
问题 I have a query which I am trying to convert into yii2 syntax. Below is the query SELECT project_id, user_ref_id FROM ( SELECT `project_id`, `user_ref_id` FROM `projectsList` WHERE user_type_ref_id = 1) AS a WHERE user_ref_id = '.yii::$app->user->id; I am trying to convert it into yii2 format like $subQuery = (new Query())->select(['p.project_id', 'p.user_ref_id'])->from('projectsList')->where(['user_type_ref_id' => 1]); $uQuery = (new Query())->select(['p.project_id', 'p.user_ref_id'])->from(

How to update multiple images in kartik Upload widget?

偶尔善良 提交于 2019-12-11 14:07:51
问题 Here i can only able preview the images on update the model. I want to load the images properly so user can remove one r more file and update will work accordingly Here is my controller public function actionUpdate($id) { $model = $this->findModel($id); $session_data = \common\models\Customer::find()->where(['user_id' => $model->customer_user_id])->one(); $towing = \common\models\TowingRequest::find()->where(['id' => $model->towing_request_id])->one(); $images_old = \common\models\Images:

How to convert get perticular field from PHP array to an array in Javascript? [closed]

若如初见. 提交于 2019-12-11 13:23:46
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 3 years ago . After click on search button get the mobile number and hit database. if result not null then this fname,lname....all field open with fill form like update form but if result not get it will be open empty.... For that I am write one function on search button this button get mobile number and call

Multiple Variables to be passed in URL - Yii2

荒凉一梦 提交于 2019-12-11 13:14:59
问题 I want to generate URL's that can handle multiple parameters as follows. www.mysite.com/index.php/controller/param1/param2/param3/param4/mySlug But still be able to be flexible and pass over less information www.mysite.com/index.php/controller/param1/parama/my_slug_2 We could assume there's always a slug at the end if that makes this easier. Is there anything in the Yii2 urlManager I can implement this. 回答1: Just configure your rule with default values of your params like this: 'urlManager' =

Yii2: has_many gridview and detailview

百般思念 提交于 2019-12-11 12:46:08
问题 I'm going to use 1st normalization form in my Yii2 project, so I've added table like this | id | post_id | tag_id | and when I'm to posts model I've writed this: public function getTags() { return $this->hasMany(PostTags::className(), ['post_id' => 'id']); } In view widget I've added 'tags.tag_id', but it shows no data. Is there any way to show this tags in DetailView and GridView widgets? May be, I can write "group_concat" somewhere? 回答1: I'd recommend to write a widget for displaying a

Mysql - Recursive Query for only the parent categories

99封情书 提交于 2019-12-11 12:16:36
问题 I have the following table category : id | desc_cat | parent_id 19 | Personal | (null) 20 | Credit Card | 19 21 | Academy | 19 22 | Home | (null) 23 | Water | 22 24 | Energy | 22 25 | Rent | 22 And I have a table containing entries with name cashbook : id | value | category_id | date 177 | 480.55 | 20 | 2016-05-01 178 | 100.00 | 24 | 2016-05-04 179 | 580.00 | 25 | 2016-05-05 180 | 80.00 | 21 | 2016-05-09 181 | 28.00 | 23 | 2016-05-11 I need to make an appointment in cashbook and return the