I don’t know how to save a change from a drop down menu to a database.
I grab the list from a database.
$list_categories = ORM::factory('category')->find_all()->as_array('category_id','category_name');
I grab the selected category that is already saved in the database.
$selected_category = $edit_forum->category_id;
I echo the drop down menu.
Form::select('category', $list_categories, $selected_category);
Let’s say it lists A, B, C. B is the current selected category and I want to change it to A. I want to save this change to the database, but don’t know how.
I currently do the following to save to the database:
$edit_forum->values($this->request->post());
$errors = array();
try {
$edit_forum->save();
$this->request->redirect('acp/forums');
} catch (ORM_Validation_Exception $ex) {
$errors = $ex->errors('validation');
}
The above works fine with text fields, but not the drop down menu.
Edit: My problem seems to be that I can’t change the category_id. Anyone know how? category_id is a foreign key.
I figured it out. My routes, rules, and labels were wrong.