Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Dynamic Dropdown in the Stand Alone Entry Form (See related posts)

The problem: you are hand-coding the stand alone entry form, but it includes several dropdowns that you don't want to hand code. Here's a bit of coding to use for any dropdowns that you want to pull the options as filled in the Custom Fields area of the Admin panel.

In this example, I'm pulling the data for a field that has an ID of 13 - change this as needed. :)

<select name="field_id_13">{exp:query sql="SELECT field_list_items FROM exp_weblog_fields WHERE field_id = '13' "}
<?
$items ="{field_list_items}";
$items = explode("\n", $items); 
$howmany = count($items);
$i = 0; do { 
$item_id = $items[$i];
?>

<option value="<?=$item_id?>"><?=$item_id?></option>
<? 
 $i++; } while ($i < $howmany); ?>
{/exp:query}</select>

You need to create an account or log in to post comments to this site.


Click here to browse all 5146 code snippets

Related Posts