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.

Phalcon\Forms\Element\Select custom label

I have a simple table with (lets say three collumns)

id         (primary key int)

name       (varchar)

deleted    (tinyint)

and what i'm trying to do it build a select like this

    $Select = new Select('t', MyTable::find(), array(
        'using' => array('id', 'name'),
        'name' => 't[]',
        'multiple' => 'multiple'

the only thing i would like to add is...

if the field deleted is 1, concat ' - deleted' with the column name in the select...

Any ideia how to perform it?

Thank you


In my opinion the best thing to do i a foreach on your MyTable::find() to set the name


when i need "custom" select stuff, i just build the options for the select myself



{% for cat in this.view.getVar("categories") %]

<option value ="{{cat.getId()"> {{ cat.getName() }}</option>



well a 'simple' workaround i found was using afterFetch on the model... and change the name propertie or add a new propertie for specific cases...

public function afterFetch() {
        $this->name .= ' - deleted';


        $this->nameForSelect =  $this->name . '  - deleted';
        $this->nameForSelect = $this->name;