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

Phalcon Form Select

Is there any way to remove a option in Phalcon's Form Generator?

$form->add(new Select("select", ArticleCategories::find(), [
'id'    => "select",
'class' => "form-control",
'using' => ['_', 'name'],
]));


1.7k
Accepted
answer
edited Aug '15

Try this:

if the unwanted option is "enemy", simply pass it as a "where-not-equal-to-NAME" filter in the find() params ie

ArticleCategories::find("name != 'enemy'")

or into a variable then into it

$unwanted = 'enemy';
ArticleCategories::find("name != '$unwanted'")

to give:

$form->add(new Select("select", ArticleCategories::find("name != 'enemy'"), [
'id'    => "select",
'class' => "form-control",
'using' => ['_', 'name'],
]));

Good luck

<3 Phalcon!



1.7k

Did my reply not solve your problem?

Thanks , i'll try it out !

Try this:

if the unwanted option is "enemy", simply pass it as a "where-not-equal-to-NAME" filter in the find() params ie

ArticleCategories::find("name != 'enemy'")

or into a variable then into it

$unwanted = 'enemy';
ArticleCategories::find("name != '$unwanted'")

to give:

$form->add(new Select("select", ArticleCategories::find("name != 'enemy'"), [
'id'    => "select",
'class' => "form-control",
'using' => ['_', 'name'],
]));

Good luck

<3 Phalcon!