It looks like you're new here. If you want to get involved, click one of these buttons!
$fields["fahrzeuge"]["order"] = 30;
$fields["fahrzeuge"]["mode"] = "checkbox";
$fields["fahrzeuge"]["model"] = array('' => array('fahrzeuge' => 'get_mission_vehicle_list'));
public function get_mission_vehicle_list() {
$this->db->order_by('precedence asc');
$this->db->select('id, name');
$this->db->where(array('published' => 'yes', 'retired' => 'no', "ist_abrollbehaelter" => "no"));
$query = $this->db->get('fahrzeuge');
return $query->result_assoc_array('id');
}
Comments
//... $fields["exists_fahrzeuge"] = array('type' => 'hidden', 'value' => 1);
This doesn't happen.
Before I updated the CMS to the most actual version with the new unique index in the database I had the issue that on saving everytime all the ticked checkboxes where added to the relationship table, so that at the end I had multiple duplicates. But this issue now cannot happen anymore because of the unique index.
I somehow set $clear_related_on_save to FALSE. I cannot remember why I did that during development... but setting to true worked ;-)
I have 2 has_many relationships in my missions_model: mission_images and mission_vehicles.
In my create and edit form I only want to display the vehicle relation. The images relation is maintained the opposite way via the mission_images model, because there are so many images that it wouldn't be practical to display them in the missions model.
The vehicle relation is maintained via checkboxes in the missions model.
mission_images is set to hidden via type => hidden.
Now on saving a mission the relations to vehicle are deleted and newly inserted correctly becaus of the checkboxes.
But the image relation is only deleted on not newly inserted... I think its because the old assignements aren't in the POST request.
Is there an out-of-the-box way to handle this or do I have to implement some hook to prevent the mission_images relation from being deleted...?