Php 如何在phalcon中填充表格中的选择选项?
我有一个列表,其中包含带有Php 如何在phalcon中填充表格中的选择选项?,php,html,phalcon,Php,Html,Phalcon,我有一个列表,其中包含带有id名称和状态的标签,在表格和我的型号标签标准中,我有: const STATUS_APPROVED = 1; const STATUS_DISABLED= 0; public $id; public $name; public $status; public static function getAllTag() { $tags = TagsStandard::find(array( "status = 'STATUS_APPROVED'
id
名称
和状态
的标签,在表格和我的型号标签标准
中,我有:
const STATUS_APPROVED = 1;
const STATUS_DISABLED= 0;
public $id;
public $name;
public $status;
public static function getAllTag()
{
$tags = TagsStandard::find(array(
"status = 'STATUS_APPROVED'",
"order" => "id"
));
}
因此,我得到了所有的标签。现在在控制器的索引
中,我有:
$tags = TagsStandard::getAllTag();
if ($tags) {
$this->view->tags = $tags;
$this->view->name = array("name" => $tags->name->toArray());
}
在索引中,我有:
<select id='user-skills-input' class="select-chosen" type="text" data-role="tagsinput" value="" multiple>
<?php if(count($tags) > 0): ?>
<?php foreach($tags->items as $idx => $tag):
echo "<option value='" . $tag->id . "'> " . $tag->name . "</option>" ?>
<?php endforeach; ?>
<?php endif; ?>
</select>
<?php
echo \Phalcon\Tag::select(array(
"user-skills-input",
TagsStandard::find(array(
"status = 'STATUS_APPROVED'",
"order" => "id"
)),
"using" => array("id", "name")
);