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

initialize Form with parameter doesn't work

Hi,

In the documentation of Phalcon

https://docs.phalcon.io/en/latest/reference/forms.html

says I write it correctly but it doesn't work:

$form = new SpecialForm("Foo", "Bar");

class SpecialForm extends Form
{   
    public function initialize($para, $meter)
    {
        print_r("para");
        print_r($para);
        print_r("meter");
        print_r($meter);

it only displays: parameter

please help me!



2.0k
Accepted
answer
edited Jul '14

Cause the first parameter needs to be an object (ig.: a model) and the second is an array(ie.: everything but need to be array, you can pass your individual parameters): https://docs.phalcon.io/en/latest/api/Phalcon_Forms_Form.html

public __construct ([object $entity], [array $userOptions])

Great, thank you so much!