Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Wrap Fieldset elements with divs
  • I'm using Bootstrap styling for my form and am hoping to accomplish the following: <.div class="control-group">
    <input id="one"/>
    <input id="two"/>
    <./div> I'm looking for a way to basically wrap "control-group" div around the two input fields using Fieldset. Is there a way to utilize the add() method to add a div? Or another way? Thanks!
  • The HTML for a fieldset is generated using the template, and that is valid for the entire fieldset. If you need specials, you'll have to generate the form manually, using
    <.div class="control-group">
    <?php echo $fieldset->field('one')->build() ?>
    <?php echo $fieldset->field('two')->build() ?>
    <./div>
    

    In 1.4/develop the fieldset has new enable/disable methods
    <.div class="control-group">
    <?php echo $fieldset->field('one')->build() ?>
    <?php echo $fieldset->field('two')->build() ?>
    <./div>
    <?php echo $fieldset->disable('one')->disable('two)->build() ?>
    
    instead of generating the entire form using individual fields.
  • Thanks! I have one other question I'm sure you can help me with. I'm doing all of my fieldset coding within my controller and passing it to the view as a variable that is then echoed. The problem is that it is displaying the whole string and not being encoded as html for my browser to interpret. What's the best way to fix this? Thanks again!
  • If you don't build in your view (which is the preferred solution) but generate the HTML in your controller, you'll have to disable output escaping when passing it. Fuel by default escapes everything sent to a view.
    $myview->set('fieldset', $fieldset->build(), false); // escaping is disabled here since it contains HTML
    

Howdy, Stranger!

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

In this Discussion