Questions tagged [yii2-advanced-app]

Yii 2 Advanced Application Template is a skeleton Yii 2 application best for developing complex Web applications with multiple tiers. The template includes three tiers: front end, back end, and console, each of which is a separate Yii application. The template is designed to work in a team development environment. It supports deploying the application in different environments.

##Resources

2222 questions
53
votes
2 answers

Performing raw SQL queries in Yii2?

I have written the below queries as I migrate my PHP website to the Yii2 framework. I want to add them to my controller so as to display the top 10 bets won. I have tried going through many Yii2 database classes but I cannot get it to work. My…
Lenny Carmi
  • 763
  • 1
  • 6
  • 12
27
votes
25 answers

Yii2: How to add textarea in yii2

What is the mapping of textarea in yii2 ? How to write this in yii2 format? What is an alternative or way to define textarea in yii2?
user4428957
26
votes
5 answers

Get response in JSON format in Yii2

I'm trying to convert and array of response into JSON format. I have tried all the answers that were posted on SO and other websites like web1,web2 adding header('Content-Type: application/json') and then echo…
ASN
  • 1,655
  • 4
  • 24
  • 52
19
votes
6 answers

Yii2 cors filters error that No 'Access-Control-Allow-Origin' header is present

Following This question i have set my rest controller behaviour as public function behaviors() { $behaviors = parent::behaviors(); $auth= $behaviors['authenticator'] = [ 'class' => HttpBearerAuth::className(), 'only' =>…
Geoff
  • 6,277
  • 23
  • 87
  • 197
18
votes
4 answers

yii2 ActiveForm numeric textfield

I've created an ActiveForm using yii2 like this: field($item, 'finalPrice', [ 'options' => [ 'tag' => 'div', …
Ofershap
  • 687
  • 2
  • 7
  • 22
18
votes
2 answers

yii2 navbar with dropdown

After some simple edit on the default navbar, I got the code for the menu below... It would be very ugly if I add more menus. 'My Project', 'brandUrl' =>…
beginner
  • 2,024
  • 5
  • 43
  • 76
18
votes
9 answers

Yii2 dropdown selected value

I want to show selected value in Yii2 dropdown, $_GET Value: $id = $_GET["cid"]; Drop down code $form->field($model, 'userid') ->dropDownList( [User::getUser()], //[ArrayHelper::map(User::findAll(['active' => '1']),…
Muhammad Shahzad
  • 9,340
  • 21
  • 86
  • 130
15
votes
2 answers

LIMIT is not working in ActiveDataProvider

I am using following code and the limit doesnt work. But if I see the command than it shows limit in that, but when I pass the query to ActiveDataProvider it fetch all the records: $data= User::find()->where(['category_id'=> 5])->orderBy(['rand()'…
Mike Ross
  • 2,942
  • 5
  • 49
  • 101
14
votes
7 answers

Set global language value in Yii2 application

Where can I set language (based on user's cookie) globally? How to make it work in the whole application (controllers,views, etc.) ? In documentation I found \Yii::$app->language = ''; but, where I can write my logic to change the language in right…
bxN5
  • 1,430
  • 2
  • 16
  • 27
14
votes
2 answers

What the idea behind environment folders in Yii2 and how to use it?

I've read through Yii2 documentation several times. I also googled and I couldn't find anything useful yet. The problem is I do not understand the concept of the environment folders. Please let me explain: I can use branches in Git (for dev,…
Roman Podlinov
  • 23,806
  • 7
  • 41
  • 60
13
votes
4 answers

How to get current module object from model in Yii2

I have module ticket. Module class has propery UserClassName (string). In this module I have model called Dialog. Within this model, I want to get access to the module property UserClassName. How I can get module object from my model Dialog? P.S.…
LostDok
  • 155
  • 1
  • 2
  • 10
13
votes
8 answers

Exception 'could not find driver' while migration in yii2

This my stack trace: Exception 'yii\db\Exception' with message 'could not find driver' in /opt/lampp/htdocs/advanced/vendor/yiisoft/yii2/db/Connection.php:534 #0 /opt/lampp/htdocs/advanced/vendor/yiisoft/yii2/db/Connection.php(836):…
akhil
  • 347
  • 1
  • 3
  • 16
12
votes
1 answer

Where to put common resources in yii2 advanced?

I want to access my css and javascript files in both frontend and backend. So, my question is where i put css and javascript files so they are accessible for both frontend and backend. Or is there any way to reuse files i.e. i put my css file in web…
Yasin Patel
  • 5,624
  • 8
  • 31
  • 53
12
votes
2 answers

Order by rand() in yii2

I want to write following query in yii2, but I can't get the expected output: SELECT * FROM user where category_id=5 ORDER BY rand() LIMIT 4 For that I have done following: $data= User::find()->where(['category_id'=>…
Mike Ross
  • 2,942
  • 5
  • 49
  • 101
12
votes
3 answers

YII2 : Add Dynamic form fields and their validations

I am adding dynamic form fields onChange of dropdown. Both types of fields are coming from different models and go to the database in different tables. I have already defined validation rules in models. But validation are not working properly. My…
WpTricks24
  • 815
  • 1
  • 7
  • 26
1
2 3
99 100