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.

Form how to add related elements

Hello Guys,

I am pretty new to the Phalcon, mostly worked with Symfony2 where form builder was awesome.

Can someone just lead me to the answer, that how can we add entity element to the form.

Let's suppose I have a campaign form, there I need to select countries/languages/domains lists. How can it be done?

Thanks in advanced.



$form = new Phalcon\Forms\Form();

$form->add(new Select('languages', ['EN' => 'English']);

Thanks, The thing I was missing to put entity name, it fixed now.

$category = new Select('category_id', Categories::find(), [ 'using' => ['id', 'name'], 'useEmpty' => true, 'emptyText' => '...', 'emptyValue' => '' ]);


``` $form = new Phalcon\Forms\Form();

$form->add(new Select('languages', ['EN' => 'English']); ```


The name is the first param always when creating a tag. The ID will be the same as the name until you specify it:

$form->add(new Select('languages', ['id' => 'myLanguagesSelect'], ['EN' => 'English']));