Questions tagged [yii2]

Yii 2 stands as the cutting-edge iteration of the acclaimed Yii framework. This powerful PHP framework offers unparalleled performance and is designed with a component-based approach.

Is it possible to establish GEO filters for distance searches utilizing Yii2-Sphinx?

I've been having success with the Yii2-sphinx extension, but now I'm looking to implement distance search using sphinx. Specifically, I need to set latitude and longitude filters for a given postcode on my index. How can I go about setting up the ...

How to use an array of parameters with Yii2's createUrl() function?

As per the instructions provided in the Yii2 documentation, the recommended way to construct a URL is as follows: $appUrl = Yii::$app->urlManager->createUrl([Yii::$app->controller->id . '/' . Yii::$app->controller->action->i ...

Creating a centralized controllers folder for a yii2 project

I am looking to integrate a shared controller directory into my Yii2 project. Inside my frontend/config/main.php file, I have the following setting: 'controllerNamespace' => 'frontend\controllers', My goal is to include both ...

Tips for handling Vue/Axios JSON payload sent data in Yii2

After spending some time trying to figure it out, I finally realized the solution, which was a bit obvious. I am sharing my answer here so that others can benefit from it and also to see if there is a more efficient way to handle this issue. The problem I ...

What could be causing my ajax function to fail on yii2?

Hello there, I am seeking guidance on how to implement an ajax function in yii2. I am currently developing a product within the yii2 framework and wish to incorporate charts such as chartJs, googleChart, or d3. In the index file of the backend area (xx/xx ...

Customizing response class in a Yii2 module

I recently created a bespoke response class and attempted to integrate it within a module. Despite returning an array of results in the controller action, the custom response class failed to be utilized as expected. Instead, the default yiiwebResponse ...

Enabling drag and drop functionality for elements in Yii2

I am looking to create draggable elements in a Yii2 advanced application. I have tried using PHP and HTML examples similar to http://jqueryui.com/draggable, but so far it has not been successful. Can anyone provide assistance? Below is the code from the vi ...

Utilize an Ajax request with the LinkPager generated through the renderAjax function

Essentially, I employ standard AJAX methods on action1 to transmit a request to action2, retrieve the produced data, and exhibit it on action1. In action2, which is accessed via a basic JS AJAX request, I return a page that has been rendered by renderAjax ...

Retrieve the values of the rows that have been selected in the Kartik GridView located within a modal, and then transfer

I am attempting to extract data from a Bootstrap modal (which contains a table of Kartik GridView) and pass the selected value to the parent form (an action create form). Can anyone provide guidance on how to achieve this? The modal form includes fields su ...

Customizing the search functionality in Yii2 gridview to implement asynchronous data retrieval using

Currently, I am using the Yii2.0 search functionality and have encountered a situation where the ajax search works effectively when displaying the grid as is. However, I need to modify the layout (refer to the screenshot below) in order to conduct the sear ...

Selecting a checkbox that lacks any specific attributes

My predicament revolves around a certain checkbox that lacks any distinguishing attributes for identification. Despite my attempts with xpath, I have not been able to successfully interact with it. Below, you will find the complete HTML code snippet where ...

Implementing captcha on specific functionalities in Yii2

Dealing with a model that includes a captcha has been challenging. I am able to successfully create new records using a form with captcha, but encountering an issue when attempting to update the data. An error message stating "The verification code is in ...

Mastering Yii2: Implementing Javascript Functions such as onchange() in a View

One of the elements in my project is a checkbox: <div class="checkbox"> <label> <?= Html::checkbox('chocolate', false) ?> Chocolate </label> </div> In addition to that, I also have a span ta ...

Prevent Yii2 Pjax Gridview from altering the base URL for pagination when utilizing an action button

I recently stumbled upon a piece of code that I am currently working with. It is a Yii2 Gridview integrated with Pjax and action buttons. One interesting feature is that when the delete button is clicked, the pjax loads the delete route which in turn delet ...

Guide for displaying retrieved information on a Bootstrap Modal window following data submission in Yii2

I'm encountering an issue with a Modal popup that contains two fields. The first field is used to submit information and perform an internal database query, while the second field should display the returned data. Oddly enough, when testing the functionali ...

In Yii2, is it possible to set the width for a specific column in the GridView widget?

Is there a way to specify the width for a certain column, such as 'file_name', in my Yii2 GridView? I've tried some suggestions from here, but none of them seem to work for me. I have also considered making columns resizable, but I'm unsure about how to i ...

Issue with Reactjs API Call not functioning properly within Yii2

I am just starting to learn React js and I am using Yii2 as my backend. When I make an API request to Yii2, it returns a 500 error. I am not sure where I have gone wrong in my code. Below is my ReactJs code for the API call: fetch('localhost/learning-rea ...

Distinguishing Between init() and __construct() in Yii2: A Comprehensive Comparison

Initialize() method : public function initialize() { } Constructor() method: public function constructor() { } Therefore, what sets them apart and which one should be employed? ...

Is it possible to input regular characters in a search model and have the results display all queries containing a combination of basic and special characters in Yii2?

As a newcomer to Yii2, I appreciate your understanding. I am currently using MariaDB as my database engine. For instance, if I input 'bosiljcic' in the queryParams and there is no exact match in the database, I receive an empty string response from the A ...

Yii2 Gridview - Horizontal Scroll Bar at the Top of the Page

I found a helpful post on Stack Overflow about creating a Yii2 Gridview with a fixed first column (Yii2 : Gridview with fixed first column), and now I'm looking to add a horizontal scrollbar at the top of the grid. My users really appreciate being able to ...

Yii2 passwordHash function generates unique values

I have experience creating apps using Yii2, but I am encountering an issue with the login functionality. It seems that the passwords are not matching up. _form.php <?= $form->field($model, 'first_name')->textInput(['maxlength' => true]) ?> ...

Effortlessly Store Various Image Files with the Kartik FileInput Tool

I'm currently working with the Yii2 PHP framework and utilizing Kartik's FileInput widget in my project. I followed this guide on handling multiple file uploads, but unfortunately, it didn't function as expected in my setup. MongoDB serves a ...

Creating input fields dynamically within Yii2 framework

I'm currently facing a challenge with forms in Yii2. My objective is to design a form that includes three dropdown menus, inquiring about the user's preferred time(s) during the week. The first menu will focus on selecting days of the week, while ...

add to a visual representation of a chart in a separate database

Having an issue with yii2 and in need of assistance: I have two databases, db1 and db2, both on MsSQL. In db2, there is a view linked to a table in db1. The problem arises when I try to insert into db2 as I am unable to retrieve the transaction id using ...

After populating dropdown values with Ajax in Yii2 Kartik, the dependent dropdown does not update the selected value through Ajax

Are you looking to update the selected value of a dependent drop-down menu? Even after using ajax to load values into the dependent drop-down, the following code does not seem to be working: $("#dependentDropDownID").select2("val", data); This code appea ...

What is the process for invoking a different DetailView::widget from a separate model within a single view in YII2?

I recently started using the Yii2 framework. I have successfully displayed data for a table using DetailView::widget. Now, I am trying to call another DetailView::widget for a different table and display it on the same view. Can someone help me with this? ...

"Encountered Yii2 SMTP issue with error code 500 5.5.1 - Command

Within my Yii2 application, I have a contact form that utilizes Swift to send emails. The configuration of my application is set up as follows: Below are the configurations found in web.php: 'mailer' => [ 'class' => &ap ...

Using Yii2 Active Record to find records where a field value is divisible

When working in SQL, I was able to select records where their IDs are divisible by 4 using the following query: SELECT id FROM table_name WHERE id%4 = 0; However, when attempting this in Yii2 active record, it resulted in an error: $model = Verses::find() ...

How to Set Up PECL Intl on MAMP 2.2 Running PHP 5.5.3

After installing the Yii2 framework, I decided to run requirements.php to check if all PHP extensions were loaded properly. To install icu4c, I used brew: brew install icu4c I also installed intl using PECL like this: /Applications/MAMP/bin/php/php5. ...

Disabling Bootstrap Js, JQuery, and CSS in Yii2

Can anyone suggest an alternative to using bootstrap.css and bootstrap.js? I've attempted the following: 'assetManager' => [ 'bundles' => [ 'yiiootstrapBootstrapAsset' => [ 'css' => [], ], ], ], While th ...

Yii: the sequel to the query parameter

I am attempting to query my database in Yii framework. $query = Task::find() ->where([Task::tableName().'.parent_id' => 0]); $query->leftJoin(TaskModel::tableName(), [TaskModel::tableName().'.task_id' => Task::table ...

Setting up a job scheduler with Mysql and PHP for Crone tasks

Within my database, there exists a table known as 'vehicle master' that contains various fields related to vehicles. vhcl_no department vhcl_type vhcl_make fuel_type chassis_no engine_no manufacture_on cubic_capacity rcbook_no rcbook_valid_till ...

Conclusion of Tour when an event is triggered by the parent view - Intro.js

File Manager - Home Normal https://i.stack.imgur.com/7C5lH.png I primarily utilize AJAX callbacks for most of my content. Whenever I click a link button on the page, it triggers a modal pop-up using jQuery events and a specific class. The Tour Guide implem ...

Obtaining additional information through ajax in Yii2

I have encountered an issue where, while receiving data from an ajax call, I am also getting unnecessary data such as all the contents of my PHP files. The problem is illustrated in the image below. How can I resolve this issue? https://i.stack.imgur.com ...

Tips for showcasing information beneath a title on a webpage in Yii2 without duplicating the header

Looking to pass an array to my view that includes headings and corresponding content lists. The structure of my array is as follows: Array ( [0] => Array ( [trimester] => Trimester1 [subject] => ABC ) ...

The Express.js application is unable to access the cookie that was previously set before initiating the route

After successfully logging in to my Yii2 + angularjs page, I store user data in a cookie using the following code snippet: $jwt = JWT::encode(array(1,2,3), 'myKey123') setcookie('myData', $jwt, time() + 3600); In order to access this ...

Conditional validation for uploading image files using Yii2

As a beginner in Yii, I am seeking guidance on applying image validation for .svg and .png files only when the user selects an image. public function rules() { return [ [['logo'], 'file', 'extensions'=&g ...

Mastering the art of organizing fields and labels in a yii2 bootstrap active form for optimal user experience

I'm currently working on the Yii2 Bootstrap active form and I have a requirement to group multiple inputs within one form group. For example: <div class="form-group field-phn required"> <label class="control-label" >Home ...

Dealing with incoming data in a yii2 RESTful service

When sending an array using $http post, I follow this approach: var results = services.transaction('orderdetails/insert', {customer_id: $scope.order.customer_id, data: $scope.orderDetail}); The variable $scope.orderdetail ...

Issues encountered with sending post requests to a yii2 application when using Angular4

After implementing the following code: this.http.post('http://l.example/angular/create/', {name: 'test'}).subscribe( (response) => console.log(response), (error) => console.log(error) ); I encountered an error on ...

Unlocking the power of YII2 to access data within multiple levels of relations using the hasMany method

There are 3 tables: Network, Company, Departments Information for Network id Name 1 Network1 2 Network2 Details for Company id network_id name 1 1 Company 1 2 1 Company 2 Departments Summary id company_id name 1 1 Dep 1 2 ...

Resolving the issue of data transmission within Yii2's framework: Page-to-page data

I'm currently using Yii2-advanced-app and I have encountered an issue. I want to pass the selected value from a dropdown menu to a PHP code that displays a list with checkboxes on the same page. Here is an image for reference on what I am trying to achieve ...

Obtaining the uploaded file in the Controller that was uploaded using the yiihelpersHtml::fileInput method in Yii2

I included the following code in my form: <?php echo Html::fileInput('imageFile', '', array('id' => 'contentForm_imageFile' )) ?> Then, I attempted to retrieve the file in the controller using this code: $newsModel->imageFile=UploadedFile::g ...

"Exploring the interactive features of a dual-axis line and column Highchart, focusing on dynamic percentage drill

In our current project, we are customizing graphs to meet a specific client requirement. The majority of the graphs we are working on involve a combination of line and column charts. Each graph requires a dropdown with a minimum of two levels, sometimes ex ...

Suggestions for incrementing a button's ID every time it is clicked

I am working on a button functionality that increases the button id when clicked. Below is the HTML code for the button: <input type="button" id="repeataddon-1" name="repeataddon" class="repeataddon" value="add" > Accompanied by the following scr ...

Separate authentication module in yii2 framework

Currently, I am facing an issue with my Yii2 setup where I have 2 modules and I want to enable users to log in separately to each module using a different IdentityClass. However, once a user logs into one module (let's say Module A), they are automati ...

Ways to tackle my code's linked dropdown issue without the use of extensions

When I selected the Id Province, I couldn't select the Id City. How can I fix this issue? Controller code snippet to address this: View code snippet for the same: ...

How can I fetch data from SQL using JavaScript based on a specific value in PHP?

My application is built using the Yii2 framework. Within my application, there is a view.php file that consists of an element and a button. The element, <div id="userId">, contains the user's login ID, and I aim to use the button to re ...

Guide on resuming a script after the AJAX response has been delivered to the user in Yii2

When an AJAX request is received, I need to provide feedback to the user before the PHP script completes its process which could take a long time. I attempted to use the send() method of the yiiwebResponse object for this purpose. Here's what I tried wi ...

Encountered an error while migrating in Yii2: Unknown property "backuprestore" in the yiicaching

I understand how the migration process works and have previously created migration files. I began by creating a migration file using the following command: php yii migrate/create implants_type This resulted in the following code being generated: <?ph ...

Transforming a raw SQL query into an ActiveRecord in Yii2

I have a complex query that I need assistance with. select t.id, t.ad_id, sum(t.impression) total_impression, sum(t.view) total_views, sum(t.clicks) total_clicks, t.publisher_id, i.budget, i.name_of_campaign from (select id, ad_id, ...

Having trouble getting Yii2, Select2, and Optgroup to work together with Ajax

I am currently utilizing Yii2 along with Select 2. I have attempted to implement examples involving optgroup that are loaded through ajax. The browser sends requests, but unfortunately nothing is displayed when I attempt to print the results. Below is the ...

A guide to updating Grid View with Pjax in yii2

Let me begin by outlining the setup I currently have: --A database table named "cases" This table stores all the cases to be displayed in a grid view --Three tables: Category, Subcategory, and ChildCategory The cases in the "cases" table are linked to ...

Kartik's gridview in yii2 has a unique feature where the floating header in the thead and tbody are

I'm looking to create a table gridview with a floating header, where the tbody and thead are not the same. The image appears after refreshing the page, before the modal is refreshed. After refreshing the modal, this modal is inside pjax and it sets t ...

insufficient accuracy in time measurement using asTime()

I am trying to update the timestamp column in my Grid view to display the date and time in my local timezone. [ 'format' => [ 'class' => 'yiii18nFormatter', 'timeZone' => 'Asia/Singapore', ], 'attribute' => 'created_ ...