Steven Kovar - Interactive Designer

Tech Journal

Latest Entries

Tech and Design

iPhone

Web

Motion

Preselecting Pulldowns in ExpressionEngine Standalone Edit Forms

June 02, 2010

This is for EE 2.0, and if you are using an earlier version, skip the system hack.

To create a Stand-Alone-Edit form, first follow the method graciously shared by Ty Wangsness, of eMarketSouth:

http://www.emarketsouth.com/blog/details/how-to-create-standalone-edit-forms-in-expressionengine-2.0/

Beware that you need to perform a small hack to your EE system. When I do this, I keep a text file with my site files in which I record any hacks or alterations I've made so I have a list of things to be aware of when upgrading the system.

Pre-selecting pull-downs

Imagine that you have a list of options in a custom field pulldown menu, as follows;

<select id="field_id_01" name="field_id_01">
    <
option value="option1">option1</option>
    <
option value="option2">option2</option>
    <
option value="option3">option3</option>
    <
option value="option4">option4</option>
</
select

Just use a conditional to compare your pulldown options with the information stored for that entry in the database, in conjunction with the HTML "selected" feature;

<select id="field_id_01" name="field_id_01">
    <
option value="option1" {if channel_fieldName == "option1"}selected="selected"{/if}>option1</option>
    <
option value="option2" {if channel_fieldName == "option2"}selected="selected"{/if}>option2</option>
    <
option value="option3" {if channel_fieldName == "option3"}selected="selected"{/if}>option3</option>
    <
option value="option4" {if channel_fieldName == "option4"}selected="selected"{/if}>option4</option>
</
select

Now your pulldown form fields should be preselected with the current value from the database.


Reader Comments


There are no comments yet.

Leave a Comment

Commenting is not available in this channel entry.