Checked/Selected
checked, selected, options, hidden
Description
{{ checked key=$foo value=$bar }}
If value
find in key
, display checked="checked"
.
{{ selected key=$foo value=$bar }}
If value
find in key
, display selected="selected"
.
Example
Template
/*
$var = 'value';
$same = 'value';
$diff = 'not value';
*/
<input type="checkbox" name="radio" value="{{ $same }}"{{ checked key=$same value=$var }}> {{ $same }}
<input type="checkbox" name="radio" value="{{ $diff }}"{{ checked key=$diff value=$var }}> {{ $diff }}
<select name="select">
<option value="{{ $same }}"{{ checked key=$same value=$var }}>{{ $same }}</option>
<option value="{{ $diff }}"{{ checked key=$diff value=$var }}>{{ $diff }}</option>
</select>