Difference between #10 and #11 of
How to create/update a model with its related items using Listbox or CheckboxList

Revision #11 has been created by softark on Mar 15, 2018, 2:00:39 AM with the memo:

error in sample code fixed
« previous (#10) next (#12) »

Changes

Title unchanged

How to create/update a model with its related items using Listbox or CheckboxList

Category unchanged

Tutorials

Yii version unchanged

Tags unchanged

listBox checkboxList

Content changed

[...]
/* clear the categories of the post before saving */
PostCategory::deleteAll(['post_id' => $this->id]);
if (is_array($this->category_ids)) {
foreach($this->category_ids as $category_id) {
$pc = new PostCategory();
$pc->post_id = $this->
post_id;
$pc->category_id = $category_id;
$pc->save();
}
}
/* Be careful, $this->category_ids can be empty */
[...]
5 0
6 followers
Viewed: 86 713 times
Version: 2.0
Category: Tutorials
Written by: softark
Last updated by: softark
Created on: Jan 27, 2016
Last updated: 6 years ago
Update Article

Revisions

View all history