Exclude options in category drop down in form

14 posts by 2 authors in: Forums > CMS Builder
Last Post: July 30, 2014   (RSS)

By claire - July 30, 2014

I'll ask one of the senior devs here about the other question.

Try changing the select like so:

<?php list($categoriesRecords, $categoriesMeta) = getRecords(array(
    'tableName' => 'dir_categories',
    'where      => 'hidden = 0'
));
<select name="category">
<option value = "">-Select-</option>
<?php foreach ($categoriesRecords as $record): ?>
<option value = "<?php echo htmlspecialchars($record['name']);?>" <?php selectedIf($record['name'], @$_REQUEST['category']);?>> <?php echo htmlspecialchars($record['name']);?> </option>
<?php endforeach ?>
</select>

--------------------

Claire Ryan
interactivetools.com

Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

By design9 - July 30, 2014

That works but then I go back to the issue of if the user forgets to fill out a required field, then the drop down category options are not retained and user would have to refresh page to get drop down options again. Is there anyway around that without using the getlistOptions?

By claire - July 30, 2014

Yeah, same solution as what I mentioned here: http://www.interactivetools.com/forum/forum-posts.php?postNum=2234613#post2234613

If you're using jQuery, for example, you can check if the category options are set using PHP and then optionally include jQuery statements on document load to set them when the page is refreshed after an error.

--------------------

Claire Ryan
interactivetools.com

Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/