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.

initialize Form with parameter doesn't work

Hi,

In the documentation of Phalcon

http://docs.phalconphp.com/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!



1.4k
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): http://docs.phalconphp.com/en/latest/api/Phalcon%5Forms%5Form.html

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

Great, thank you so much!