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.
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?
<?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>
Re: [zick] Displaying Checkboxes from a "List" field type as a vertical column
By (Deleted User) - January 26, 2011
Thanks for the example...
I ended up playing around with it for a while longer and I was on the right track, I just didn't take it far enough. I got it working perfectly for my needs using this
Seen here: http://bostonlimos.co/fleetDetails.php?Towncar---Lincoln-Executive-L-2
I ended up playing around with it for a while longer and I was on the right track, I just didn't take it far enough. I got it working perfectly for my needs using this
<?php $amenities = getListLabels('limousinefleet', 'amenities', $limousinefleetRecord['amenities']);?>
<ul class="amenities"><?php foreach ($amenities as $amenities): ?>
<li><?php echo $amenities;?></li>
<?php endforeach ?> </ul>
Seen here: http://bostonlimos.co/fleetDetails.php?Towncar---Lincoln-Executive-L-2