yii2-advanced-app

Yii2 search with empty param throws all records

荒凉一梦 提交于 2020-01-03 05:34:10
问题 There are 3 search fields in view2.php, search is working properly when i enter something into search field and hit search button. But the problem is when I hit search/Enter button without entering anything into search fields, it displays all the entries related to that model from DB. Below is my Machine model: public function search($params) { $query = Supplier::find(); $query->joinWith(['user', 'cities', 'industrialareas','supplierMachines', 'subCategory', 'types0','supplierCertificates' ])

Yii2: Replace default confirmation message used by Gridview with Sweet alert

大城市里の小女人 提交于 2019-12-31 01:56:48
问题 I am using yii2mod/yii2-sweet-alert in my projects, I am using it on basic and advanced themes, and I love it. The question. How can I change the grid default confirmation dialog that is a plain javascript confirmation in order to use Sweet-alert to make it look better? I already tried modifying the button's template for the delete, because if you want to change the message you will do the following: [ 'class' => ActionColumn::className(), 'template' => '{update}{delete}', 'buttons' => [

Yii2: finfo_file(C:\xampp\tmp\php29C.tmp): failed to open stream: No such file or directory

99封情书 提交于 2019-12-25 18:47:16
问题 Getting error finfo_file(C:\xampp\tmp\php29C.tmp): failed to open stream: No such file or directory while uploading multiple files. tried inserting $model->save(); before saveAs() but then it upload only one file not all files, also not getting path in database for each file which is getting uploaded. Controller: public function actionCreate() { $model = new RoomTypes(); if ($model->load(Yii::$app->request->post())) { $imageName = $model->room_type; $model->file = UploadedFile::getInstances(

how to insert data to 2 tables i.e Employee and User(migrated) from single form(Employee Create) and controller in yii2

不羁岁月 提交于 2019-12-25 18:17:21
问题 this is my create page questions/create.php ` <?= $form->field($model, 'clinic_id')->dropDownList( ArrayHelper::map(Clinic::find()->all(),'id','clinic_name'), ['prompt'=> 'Select Clinic'] )?> <?= $form->field($model, 'first_name')->textInput(['maxlength' => true]) ?> <?= $form->field($model, 'last_name')->textInput(['maxlength' => true]) ?> <?= $form->field($model, 'user_name')->textInput(['maxlength' => true]) ?> <?= $form->field($model, 'password')->passwordInput(['maxlength' => true]) ?> <

mkdir(): Permission denied in Yii2

时光总嘲笑我的痴心妄想 提交于 2019-12-25 04:37:19
问题 After installing yii2, I got the following error. Some suggests that I should give full permissions to IIS_IUSRS but still to no avail. 回答1: You shouldn't need to set the permissions to 777 , that is a security problem as it gives read and write access to the world. It may be that your apache user does not have read/write permissions on the directory. If you use Ubuntu do this : Make sure all files are owned by the Apache group and user. In Ubuntu it is the www-data group and user chown -R

How to displaying the datas in Yii2 index like cardview

爷,独闯天下 提交于 2019-12-25 03:54:56
问题 I'm trying to displaying the datas (for example: projects table) in my Yii2 advanced project and i just need to know how can display these things in my index? i mean, i couldn't find any tutorial or discussion about this in the internet. but with one diffrence, i know we can use DetailView::widget or Gridview widget or something like that, but, where should i put those codes into it? i mean, how can use these widgets for each item like a cardview. exactly like below: https://play.google.com

Yii2: Use Html::tag() with HTML content for tooltip Bootstrap 3

雨燕双飞 提交于 2019-12-24 18:40:18
问题 Hint: Formating as raw won't fix my problem - See attachement respectively picture: The following code will implement tooltip using attribute title of method tag() . Unfortunately, there is no possibility rendering HTML-tags inside the title. Any ideas(links are welcome) how to implement tooltip handling my intention to render HTML tags? Is there any other option implementing tooltip-box outside attribute title , so that I am able to render HTML-tags [ 'attribute' => $dummy, 'label' => Yii::t

Yii2: ActiveForm: combine rules / multiple validation on one field

萝らか妹 提交于 2019-12-24 12:42:29
问题 LoginForm: public function rules() { return [ // username and password are both required [['username', 'password'], 'required'], // username should be a number and of 8 digits [['username'], 'number', 'message'=>'{attribute} must be a number'], [['username'], 'string', 'length' => 8], // password is validated by validatePassword() ['password', 'validatePassword'], ]; } /** * Validates the password. * This method serves as the inline validation for password. * * @param string $attribute the

How to get previous and next row model ID in yii2 gridview data row

早过忘川 提交于 2019-12-24 10:37:59
问题 While in GridView widget and displaying ActiveDataprovider results that i fetched from a customized query, i want to get next and previous row $model->id while displaying the records, what i need to do is to show links to previous and next posts while in reading mode, my gridview already generates link to the post view but there doesnt seem to be an option to get next DB row's record ID i have already tried to use default values in the function available but they dont seem to hold any related

Yii2 routing with get parameters only ( hidden controller and action )

夙愿已清 提交于 2019-12-24 08:57:48
问题 I saw routing where the controller and the action are hidden and url is constructed like www.domain.com/en/page-33/category-28/product-89?param=some_param . In this routing when I try to get the parameters with var_dump(Yii::$app->getRequest()->getQueryParams()) I got array like so : array(4) { ["first_step"]=> string(7) "page-33" ["second_step"]=> string(11) "category-28" ['product']=> string(10) "product-89" ['param']=> string(10) "some_param"} How can I do that ? I saw the rules and they