Hi
Any hints for this would be appreciated.
I have a table called "computers" which lists computer models and a sub-table which lists their "components":
id
computers_id // the id of the parent in "computers"
component_type_id // the id of the component type lookup table, could be "motherboard", "graphics card" etc.
component_name // the component name, varchar 256
In the simple module for "computers", I'd like to show all the related records in the "components" table and be able to add/delete etc. I want to be able to show the component_type_id and component_name where component_type_id is also resolved to the textual name from the lookup.
Is there an easy way to do this?
Thanks
Comments
function form_fields($values = array(), $related = array()) { $fields = parent::form_fields($values, $related); // ADD YOUR CUSTOM MODEL FORM CODE HERE if (!empty($values['id'])) { $CI =& get_instance(); $CI->load->model('computers_model'); $components = $CI->computers_model->options_list('id', 'name', array('computers_id' => $values['id'])); $str = ''; foreach($components as $key => $c) { $edit_uri = ($CI->fuel->admin->is_inline()) ? 'inline_edit' : 'edit'; $str .= '<a href="'.fuel_url('components/'.$edit_uri.'/'.$key).'">' . $c . '</a><br>'; } $create_uri = ($CI->fuel->admin->is_inline()) ? 'inline_create' : 'create'; $str .= '<br><br><a href="'.fuel_url('components/'.$create_uri).'" class="btn_field">Add</a><br>'; $fields['Components'] = array('type' => 'section', 'order' => 100); $fields['components'] = array('type' => 'copy', 'value' => $str, 'order' => 101, 'js' => '<script>$(function(){ // add your javascript here });</script>'); } return $fields; }
Is it possible to pass extra values via the add button? ie. my add button takes me to the components child form where the "computer_id" field is already populated from the parent form.
I'll come back to setting this up to work as a modal - will post my code when it works...