This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use the new forum.
Home » development » Documentation » How to format an sfWidgetFormChoice in multiple columns
How to format an sfWidgetFormChoice in multiple columns [message #92469] Fri, 29 January 2010 13:18
allyb  is currently offline allyb
Messages: 21
Registered: May 2009
Junior Member
it's taken me ages to work this out, so I thought i'd share it. The following code will put the checkbox list into 2 columns.

This example works for an embedded form (which in fact only contains an sfWidgetFormChoice):

      <?php foreach($form['categories'] as $fieldSchema => $embeddedForm): ?>
        <div class="checkboxSerie">
          <fieldset>
            <ul>
          <?php echo $embeddedForm->renderError(); ?>
          <?php
            $i=0;
            $secondColumn = false;
            $totalOptions = count($embeddedForm);
            foreach ($embeddedForm as $widget): ?>
              <?php
                $i++;
                if (!$secondColumn && $i >= $totalOptions/2):
                  $secondColumn = true;
              ?>
            </ul>
                </fieldset>
                <fieldset>
                  <ul>
              <?php endif; ?>
              <li>
              <?php echo $widget->render(); ?>
              <?php echo $widget->renderLabel(); ?>
              </li>
          <?php endforeach; ?>
            </ul>
          </fieldset>
        </div>
      <?php endforeach; ?>
Previous Topic:tutorials, books and guides
Next Topic:[TICKET] Day 9: The Functional Tests - no link
Goto Forum:
  

powered by FUDforum - copyright ©2001-2004 FUD Forum Bulletin Board Software