Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Silex + form validation

Tags:

forms

php

silex

I'm trying to create a simple form validation with Silex. Since there is no official guide to the forms extension yet, I'm following the instructions on this site: http://dev.umpirsky.com/create-kick-ass-website-in-no-time-with-silex/

For some reason, the form won't validate correctly:

$form->isValid() // will always return true

I spent some time searching for a solution (of what seems to be a known issue), but haven't found anything useful.

Did someone else encounter this problem and knows a way around it?

Thanks!

like image 220
amitayh Avatar asked Jul 04 '26 08:07

amitayh


1 Answers

you probably missed to register the validator extension

$app->register(new Silex\Provider\FormServiceProvider(), array(
    'form.class_path' => __DIR__ . '/../vendor/symfony/src'
));
$app->register(new Silex\Extension\ValidatorExtension(), array(
    'validator.class_path'    => __DIR__.'/vendor/symfony/src',
));
like image 92
Hans Stevens Avatar answered Jul 07 '26 11:07

Hans Stevens



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!