We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Merging with model data in select

Hi all.

How to merge model data with another array? For example:

//Can be static array
$vegetables = array('id' => 999, 'name' => 'Potato');

echo $this->tag->select(
    array(
        'productId',
        Products::find("type = 'vegetables'"),
        'using' => array('id', "name"),
        'useEmpty' => true,
        'emptyText' => 'Please, choose one...',
        'emptyValue' => '@'
    )
);

<select id="productId" name="productId">
    <option value="@">Please, choose one..</option>
    <option value="101">Tomato</option>
    <option value="102">Lettuce</option>
    <option value="103">Beans</option>
    <option value="999">Potato</option>
</select>


6.5k
Accepted
answer

You can try:

array_merge($vegetables , Products::find("type = 'vegetables'")->toArray())