fuel_helper - fuel_edit markers

edited March 2012 in Feature Requests
Hello there,

I was wondering, would it be possible to specify a list of fields after the | marker when calling the fuel_edit() function from a view?
So instead of just passing

fuel_edit($id.'|field_to_edit')
why not have

fuel_edit($id.'|field1, field2, field3')
no?
that would rock! sometimes you want to just exclude one field, rather than only edit one...
is that planned? Or if I wanted to hack this out myself, could you give some insight?

thanks a lot!

UPDATE: also, is it possible to control the 'delete' button? Sometimes it's safer to disallow that!

Comments

  • edited March 2012
    I think I found a workable solution:

    in /modules/fuel/controllers/module.php around line 1098

    replace

    if (!is_int($column) AND isset($fields[$column]))
    {
    // load it here again so that we can set the use_label
    $this->load->library('form_builder');
    //$this->form_builder->hidden = (array) $this->model->key_field();
    $this->form_builder->label_colons = FALSE;
    $this->form_builder->question_keys = array();
    $this->form_builder->css_class = 'inline_form';
    $single_field = array();
    $single_field[$column] = $fields[$column];
    $single_field[$column]['label'] = ' ';
    $single_field['id'] = array('type' => 'hidden', 'value' => $id);
    $vars = $this->_form($id, $single_field, TRUE, FALSE);
    }
    else {
    $vars = $this->_form($id, NULL, TRUE, FALSE);
    }
    with:

    if (!is_int($column)) {
    $columns = explode(',', $column);
    $show_fields = array();
    foreach($columns as $column) {
    $column = trim($column);
    if (isset($fields[$column])) {

    // load it here again so that we can set the use_label
    $this->load->library('form_builder');
    //$this->form_builder->hidden = (array) $this->model->key_field();
    $this->form_builder->label_colons = FALSE;
    $this->form_builder->question_keys = array();
    $this->form_builder->css_class = 'inline_form';

    $show_fields[$column] = $fields[$column];
    $show_fields[$column]['label'] = ' ';
    $show_fields['id'] = array('type' => 'hidden', 'value' => $id);
    }

    }
    $vars = $this->_form($id, $show_fields, TRUE, FALSE);
    }
    elseif (isset($fields[$column])) $vars = $this->_form($id, NULL, TRUE, FALSE);
    Now from the views you can call

    fuel_edit($id.'|field1,field2,field3');
    and only these fields will show up inside the inline editor form!

    Hope this helps others too!
  • edited 11:54PM
    Interesting fix... I'll look into possibly adding that
Sign In or Register to comment.