Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Fieldset : How to insert html code
  • Hi all,
    I would like to insert some html code in a fieldset (for example some <div> elements), but i don't see any way to do that.

    Do you know if there is a trick that i haven't seen?

    Thanks in advance.
  • HarroHarro
    Accepted Answer
    The current fieldset implementation in it's standard form is quite limited when it comes to custom html, you can only play a bit with the template values in the form.php config file.

    If you need more complex layouts, you'll have to "break up" your fieldset, and start generating fields seperately.

    So, instead of using

    echo $fieldset->build();

    in your view, you can do

    <div class="field-1">
        <?php echo $fieldset->field('field-1')->build; ?>
    </div>
    <div class="field-2">
        <?php echo $fieldset->field('field-2')->build; ?>
    </div>

    and so on. You can also enable and disable fields in the fieldset, so you can generate more complex forms.

    This will be adressed in Fuel v2, which will have more object oriented approach to form building, with custom renderers to give you a lot more flexibility to generate more complex forms. You can have a peek at it here: https://github.com/fuelphp/fieldset, some already use it in v1 applications.
  • Many thanks Harro!
    i will test the both approch while waiting for the V2 (i think that the config method will be enough for me).

Howdy, Stranger!

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

In this Discussion