XF 2.3 <xf:option question

Anatoliy

Well-known member
How do I use 'selected' attribute in XF template, like
HTML:
<option value="second" selected>Second Value</option>
?

HTML:
<xf:option value="normal" selected>Normal</xf:option>
throws me an error
"Template Compilation Error
public:av_notes_edit - Line 17: Syntax error - Template name: public:av_notes_edit
"
here is my form

Code:
<xf:title>
    <xf:if is="$note.note_id">
        Edit note
        <xf:else />
        Add new note
    </xf:if>
</xf:title>

<xf:form action="{{ link('notes/save', $note) }}" class="block" ajax="1">
    <div class="block-container">
        <div class="block-body">
            <xf:dateinputrow name="post_date" value="{$note.post_date}" label="Fishing trip date" />
            <xf:selectrow name="quality" label="Quality">
                <xf:option value="">--Please choose an option--</xf:option>
                <xf:option value="excellent">Excellent</xf:option>
                <xf:option value="good">Good</xf:option>
                <xf:option value="normal" selected>Normal</xf:option>
                <xf:option value="bad">Bad</xf:option>
                <xf:option value="skunk">Skunk</xf:option>
            </xf:selectrow>
            <xf:textarearow name="content" value="{$note.content}" label="Your note" autosize="true" rows="5" />
        </div>
        <xf:submitrow submit="{{ phrase('save') }}" fa="fa-save" />
    </div>
</xf:form>
 
Hello,

You can use this.

Code:
<xf:selectrow name="quality" label="Quality" value="normal">
    <xf:option value="">--Please choose an option--</xf:option>
    <xf:option value="excellent">Excellent</xf:option>
    <xf:option value="good">Good</xf:option>
    <xf:option value="normal">Normal</xf:option>
    <xf:option value="bad">Bad</xf:option>
    <xf:option value="skunk">Skunk</xf:option>
</xf:selectrow>
 
Back
Top Bottom