Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Fieldset::set_config()
  • I am trying to create a fieldset with custom form names rather than just form_field_name and label for form_form_field_name. I've tried all sorts of ways to do this but I can't seem to get it to work. The fieldset example at https://github.com/jschreuder/FuelDocGenerator doesn't seem to have this, how do I go about it? Also, how can I get it to generate fieldset tags? Is it possible to specify that fields are not generated in a table?
  • set_config() is meant to allow you to override items in the forms config file, so only those keys can be used. I have a very customized one that does this:
    // fetch the definition of this form
    $formdata = \Config::get('forms');
    
    // add a form header
    $formdata['form_template'] = str_replace('{legend}', __('global.information'), $formdata['form_template']);
    $formdata['form_template'] = str_replace('{info}', $info, $formdata['form_template']);
    $formdata['form_template'] = str_replace('{header}', $title, $formdata['form_template']);
    
    // add buttons
    $formdata['form_template'] = str_replace('{buttons}',
     Form::submit('formbutton[save]', __('global.save'), array('id' => 'form_formbutton[save]', 'class' => 'formbutton positive')).
     Form::submit('formbutton[refresh]', __('global.refresh'), array('id' => 'form_formbutton[refresh]', 'class' => 'formbutton', 'formnovalidate')).
     Form::submit('formbutton[cancel]', __('global.cancel'), array('id' => 'form_formbutton[cancel]', 'class' => 'formbutton negative', 'formnovalidate')),
     $formdata['form_template']
    );
    
    // create the fieldset
    $fieldset = Fieldset::forge('users')->set_config($formdata)->set_config(array('form_attributes' => array('onsubmit' => 'fuel_set_csrf_token(this)')))->add_model($model)->repopulate();
    

  • Thanks - I'll have another look through that. It'll prove helpful to cross reference with what you have provided.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion