Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
set fieldset form class and attributes
  • how can set the html class of a form generated with fieldset class.

    $form = Fieldset::forge('upload_video');
    $form -> add('title', Lang::get('title'));
    ....
    $html = $form->build();

    wher can i modify the template generated! and how can i add attribute to the <form> class ?
  • sorry, i found it,so i will answer myself :D 

    to set the form attributes you can do  :

    $form = Fieldset::forge('my_form');
    $form -> form()->set_attribute('class', 'custom');

    its mentioned at the bottom of the documentation page :
    http://fuelphp.com/docs/classes/fieldset.html#/modify_form_attributes

    and to modify the generated form template, its more easier, 
    just by copying the config file "form.php"  from the fuel/core/config/ to your app config path, and edit it.

      
  • HarroHarro
    Accepted Answer
    If you need more than one form template:

    We use a forms.php config file in our applications. Inside we have a multi-dimensional array for form definitions (i.e. every array entry holds the values you'll find in form.php). This config file is auto loaded. We use the entry 'default' for a copy of the original form.php config.

    In your code, you then do:
    $form = Fieldset::forge('my_form')
    $form->set_config(Config::get('forms.loginform', Config::get('forms.default', array())));
    which defines a custom form definition for this specific fieldset.
  • Thank you very much,this is really helpful.
    :D

Howdy, Stranger!

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

In this Discussion