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 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.0k
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.0k

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

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

or into a variable then into it

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

to give:

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

Good luck

<3 Phalcon!