Displaying Checkboxes from a "List" field type as a vertical column

3 posts by 2 authors in: Forums > CMS Builder
Last Post: January 26, 2011   (RSS)

By (Deleted User) - January 26, 2011

In a certain section, I have a list field type that is set up as a checkbox (multi-value). This is to check of certain amenities that a vehicle in our fleet has, so it may have just a few or many. Using the code generated automatically, the list displays in the browser as comma separated values on a single line.

<?php echo join(', ', getListLabels('limousinefleet', 'amenities', $limousinefleetRecord['amenities'])); ?>

I want the list to display in the browser much the way it appears in the section editor, as a single, vertical column with a checked checkbox icon in front of it. Ideally, I'd like it to be similar to an unordered list, so I have control over list-style-type, etc, but it isn't as simple as just using an unordered list (I don't think) because it's just one record.

Any thoughts/suggestions?

Re: [jkoveos] Displaying Checkboxes from a "List" field type as a vertical column

By Mikey - January 26, 2011

See if this works for your list:

<ul>
<?php $vehicleList = getListLabels('limousinefleet', 'amenities', $limousinefleetRecord['amenities']) ?>
<?php foreach($vehicleList as $vehicleListed): ?>
<?php if ($limousinefleetRecord['amenities']): ?>
<li><?php echo htmlspecialchars($vehicleListed) ?></li>
<?php endif ?>
<?php endforeach ?>
</ul>