JsFormValidatorBundle icon indicating copy to clipboard operation
JsFormValidatorBundle copied to clipboard

get_class() expects parameter 1 to be object, array given

Open Tobur opened this issue 11 years ago • 3 comments

Try to use bundle and after I put line:

include('FpJsFormValidatorBundle::javascripts.html.twig')

in my template, I have error:

Twig_Error_Runtime: An exception has been thrown during the rendering of a template ("get_class() expects parameter 1 to be object, array given") in "/home/tobur/www/cj2/vendor/fp/jsformvalidator-bundle/Fp/JsFormValidatorBundle/Resources/views/javascripts.html.twig" at line 3.

Tobur avatar Mar 14 '14 16:03 Tobur

For more clear, in my form I add field somethink like this:

    $builder->add(
        AccountingImport::KEY_RENT,
        'text',
        array(
            'attr'           => array(
                'class' => 'half-width',
                'data-bind' => 'value: '.AccountingImport::KEY_RENT
            ),
            'constraints'    => $this->accountingImport->getValidatorsByKey(AccountingImport::KEY_RENT)
        )
    );

Tobur avatar Mar 14 '14 16:03 Tobur

Array ( [0] => Symfony\Component\Validator\Constraints\NotBlank Object ( [message] => This value should not be blank. [groups] => Array ( [0] => Default )

    )

[1] => Symfony\Component\Validator\Constraints\Regex Object
    (
        [message] => This value is not valid.
        [pattern] => /^[0-9]+(\.[0-9][0-9])?+$/
        [htmlPattern] => 
        [match] => 1
        [groups] => Array
            (
                [0] => Default
            )

    )

)

Tobur avatar Mar 17 '14 09:03 Tobur

TODO: write tests to check if symfony works with two-dimensional arrays of constraints

jumale avatar Mar 17 '14 10:03 jumale