// Here Categories is some model
$categories = Categories::find([
'conditions' => 'number_posts BETWEEN ?1 AND ?2',
'order' => 'name DESC',
'limit' => 10,
'bind' => [
1 => 8,
2 => 12,
],
]);
$select = Phalcon\Tag::select(
[
'category',
$categories,
'name' => 'categories',
'emptyText' => 'Choose category ...',
'useEmpty' => true,
'using' => [
'id',
'name'
],
]
);
echo $select;
This code will generate such HTML:
<select id="category" name="categories">
<option value="">Choose category ...</option>
<option value="31">Wilkinson and Sons</option>
<option value="35">Upton-Hyatt</option>
<option value="24">Strosin-Will</option>
<option value="28">Simonis-Stracke</option>
<option value="7">Rice, Breitenberg and Upton</option>
<option value="10">Renner-Waters</option>
<option value="11">Rempel, Hodkiewicz and Quitzon</option>
<option value="22">O'Keefe-Block</option>
<option value="2">Marvin, Schoen and Pagac</option>
<option value="43">Keebler, Rosenbaum and Kessler</option>
</select>