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

Dynamic form content

I have a page which has an input parameter ie:

https://site.com/Page/index/1234

PageController creates a PageForm in indexAction($id):

Class PageController extends Phalcon\Mvc\Controller{
    public function indexAction($id){
        $form = new PageForm(null);
        $this->view->form = $form;
    }
}

In PageForm initialize() I want to pass $id to one of the form elements. So the values in this form element - which is a dropdown - should be dynamic based on the $id passed into PageController. I can't see any way to make PageForm "aware" of that $id that was passed in at runtime though. Is it in $option when I override initialize:

class PageForm extends Phalcon\Forms\Form{
    public function initialize ($entity = null, $option = null)
    ...
}

? If I do

Class PageController extends Phalcon\Mvc\Controller{
    public function indexAction($id){
        $form = new PageForm(null,array('id'=>$id);
        $this->view->form = $form;
    }
}

And then do print_r($option) inside PageForm's initialize() it is empty. Is this possible?