It looks like you're new here. If you want to get involved, click one of these buttons!
$config['modules']['fahrzeuge'] = array(
'module_name' => 'Fahrzeuge',
'instructions' => lang("fahrzeuge_instructions"),
'permission' => 'vehicles',
);
$config['modules']['fahrzeug_images'] = array(
'module_name' => 'Fahrzeugbilder',
'display_field' => 'description',
'permission' => 'vehicles',
);
class Fahrzeuge_model extends Abstract_module_model {
public $has_many = array('fahrzeug_images' => 'fahrzeug_images_model');
public $belongs_to = array('missions' => 'missions_model');
class Fahrzeug_Images_model extends Abstract_module_model {
public $required = array('description', 'fahrzeug_id');
public $foreign_keys = array('fahrzeug_id' => 'fahrzeuge_model');
$config['modules']['missions'] = array(
'module_name' => 'Einsätze',
'instructions' => lang("einsatz_instructions"),
'permission' => 'missions',
);
$config['modules']['mission_images'] = array(
'module_name' => 'Einsatzbilder',
'display_field' => 'description',
'instructions' => lang("einsatz_images_instructions"),
'permission' => 'missions',
);
class Missions_model extends Abstract_module_model {
public $required = array('name', 'datum_beginn', 'uhrzeit_beginn', 'datum_ende', 'uhrzeit_ende', 'lage', 'anzahl_kraefte', 'bericht', 'cue_id', 'type_id');
public $foreign_keys = array('cue_id' => 'mission_cues_model', 'type_id' => 'mission_types_model');
public $has_many = array('mission_images' => 'mission_images_model', 'fahrzeuge' => 'fahrzeuge_model');
public $filters = array('name', 'datum_beginn', 'ort');
class Mission_Images_model extends Abstract_module_model {
public $required = array('description', 'mission_id');
public $foreign_keys = array('mission_id' => 'missions_model');
Comments
public function options_list($key = 'id', $val = 'description', $where = array(), $order = TRUE, $group = TRUE) { if (empty($val)) { $val ='description'; } $data = parent::options_list($key, $val, $where, $order); return $data; }
So if I open the Mission Image the options list value should be datum_beginn - name
Is that possible?
$fields['my_field']['options'] = $this->my_model->options_list('datum_beginn', 'name');
The key should stay the id field. But the displayed value should consist of 2 database fields.
The problem is, that in my table I have many entries with the same name so I cannot differentiate between them in the select box... I want to have a combined value of the datum_beginn field and the name field.
I think I will overwrite the options_list method with a whole new logic.
public function options_list($key = 'id', $val = 'name', $where = array(), $order = TRUE, $group = TRUE) { $this->db->order_by('datum_beginn desc, uhrzeit_beginn desc, id desc'); $this->db->select('id, name, datum_beginn, uhrzeit_beginn'); $query = $this->db->get('missions'); foreach($query->result() as $row) { $data[$row->id] = get_ger_date($row->datum_beginn).' '.$row->uhrzeit_beginn.' - '.$row->name; } return $data; }
solved the problem!