Difference between #5 and #6 of
Creating a Dependent Dropdown From Scratch in Yii2

Revision #6 has been created by alrazi on Nov 21, 2017, 2:39:53 PM with the memo:

remove redundant queries
« previous (#5) next (#7) »

Changes

Title unchanged

Creating a Dependent Dropdown From Scratch in Yii2

Category unchanged

How-tos

Yii version unchanged

Tags unchanged

yii2, dependent dropdown

Content changed

[...]
```php
public function actionLists($id)
{

 
$countPosts = \common\models\Post::find()
 
->where(['category_id' => $id])
 
->count();
 

$posts = \common\models\Post::find()
->where(['category_id' => $id])
[...]
->all();

if
($countP (!empty($posts>0))) { foreach($posts as $post) { echo "<option value='".$post->id."'>".$post->title."</option>"; } }
 
 else{
echo "<option>-</option>";
}

}
```
[...]
4 1
12 followers
Viewed: 147 617 times
Version: 2.0
Category: How-tos
Written by: ThePr0f3550r
Last updated by: alrazi
Created on: Jul 2, 2014
Last updated: 6 years ago
Update Article

Revisions

View all history