我想使用Silex的服务提供商来构建一个简单的验证联系表单,但似乎只有翻译服务提供商,因为当我渲染视图时,我有一个Twig_Error_Syntax'过滤器"trans"不存在',我猜测是因为我必须自定义(覆盖)'form_div_layout.html.twig'并删除trans过滤器?我不需要翻译.
我还没有实现验证.
这是我的代码:
use Symfony\Component\HttpFoundation\Request ;
use Symfony\Component\HttpFoundation\Response ;
require_once __DIR__ . '/bootstrap.php' ;
$app = new Silex\Application() ;
require __DIR__ . '/../config/conf.php';
$app->register(new Silex\Provider\SymfonyBridgesServiceProvider(), array(
'symfony_bridges.class_path' => __DIR__ . '/../vendor/symfony/src',
)) ;
$app->register(new Silex\Provider\HttpCacheServiceProvider(), array(
'http_cache.cache_dir' => __DIR__ . '/../cache/',
)) ;
$app->register(new Silex\Provider\FormServiceProvider(), array(
'form.class_path' => __DIR__ . '/../vendor/symfony/src'
)) ;
$app->register(new Silex\Provider\ValidatorServiceProvider(), array(
'validator.class_path' => __DIR__ . '/../vendor/symfony/src',
)) ;
$app->register(new Silex\Provider\TwigServiceProvider(), array(
'twig.path' => __DIR__ . '/../src/views/frontend/',
'twig.class_path' => __DIR__ . '/../vendor/twig/lib',
'twig.options' => array('cache' => …Run Code Online (Sandbox Code Playgroud)