Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

How to selected in select option using Tag

In view.phtml of edit news action, i want to show all categories of news ( such as healthy, sport, joke) and selected is correct which it has before. How to do this with Tag

echo Phalcon\Tag::select(array( "2", Menu::find("id != '0'"), "using" => array("id", "name"), ));

html correct like this:

<select> <option value="1">news</option> <option value="2" selected="selected">healthy</option> <option value="3">joke</option> </select>



1.7k
Accepted
answer

Something like this:

<?php

echo Phalcon\Tag::select(array(
    "robotId",
    Robots::find("type = 'mechanical'"),
    "using" => array("id", "name"),
    "value" => 1 // This is a setDefault() shortcut for tag call
    ));

"value" => 1 // This is a setDefault() shortcut for tag call

It works. Thank you so much. I have searched in forum but i can't find it.

Please mark this as solved, then.

This should be placed in documentation.