Setting options

The simplest way to set options is with a basic string of options separated by a comma. Perch will then use each item in the string as both the visible option in the select box and the value that gets written to your HTML.

options="House, Apartment, Room-share"

Sometimes you might want to have something different displayed to the editor than gets written to the HTML. For example, the value may be used for a class attribute that needs to be lowercase with no spaces, but you want to present the choice more attractively formatted in the edit form.

You can provide a value to write to the HTML for each item by using a | character. The order is nice label first, followed by | followed by the value that gets written to the template.

options="House|house, Apartment|apartment, Room-share|roomshare"

Allowing for no selection

The allowempty attribute creates an empty option at the start of the select box to make it possible for the editor not to choose an option. Without this, one of the options is always chosen (the first by default).

Report a problem with this page

Let us know of problems or improvements that could be made to this page. This isn't for getting support - post to the forum for that.