我最近遇到了一个我解决的问题.为了解决这个问题,我结束了在我的一个表单中使用了configureOptions的setDefaultOptions.问题是它让我问,这两个功能之间有什么区别?
以下是它们在我的表单中的样子:
<?php
namespace AdminBundle\Form\Type;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
//use Symfony\Component\OptionsResolver\OptionsResolver;
Class ProjetIntType extends AbstractType
{
public function buildForm(FormBuilderInterface $constructeur, array $options)
{
$constructeur
->add('langue', 'text')
->add('nom', 'text')
->add('descriptionCours', 'text')
->add('descriptionComplete', 'text')
->add('roles', 'text')
->add('aptitudesDeveloppees', 'text');
}
/*public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
'data_class' => 'PublicBundle\Entity\ProjetInt',
));
}*/
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(array(
'data_class' => 'PublicBundle\Entity\ProjetInt',
));
}
public function getName()
{
return 'projetInt';
}
}
Run Code Online (Sandbox Code Playgroud) 我环顾四周,找不到符合我目前情况的答案.我有一个app.js文件:
'use strict';
var demoApp = angular.module('demoApp', [
// Dépendances du "module" <-- demoApp
'ngRoute',
'routeAppControllers',
'todoList'
]);
demoApp.config(['$routeProvider', '$locationProvider',
function($routeProvider, $locationProvider) {
// Système de routage
$routeProvider
.when('/home', {
templateUrl: 'views/home.html',
controller: 'homeCtrl'
})
.when('/contact/:msg?', {
templateUrl: 'views/contact.html',
controller: 'contactCtrl'
})
.when('/todolist', {
templateUrl: 'views/todolist.html',
controller: 'listeCtrl'
})
.when('/testfiltre', {
templateUrl: 'views/testfiltre.html',
controller: 'demoFiltreCtrl'
})
.when('/testCreationfiltre', {
templateUrl: 'views/testcreationfiltre.html',
controller: 'demoCreationFiltreCtrl'
})
.otherwise({
redirectTo: '/home'
});
}
]);
var routeAppControllers = angular.module('routeAppControllers', []);
routeAppControllers.controller('homeCtrl', ['$scope',
function($scope){
$scope.message = "Bienvenue …Run Code Online (Sandbox Code Playgroud) 我做了一些研究,我发现这篇文章: 如何在symfony2中创建下载生成文档的链接?
我尝试了解决方案,但它在浏览器中显示我的pdf,但我想要的是当有人点击链接时,它直接下载文件.是否可以通过Symfony实现这一目标?
KévinDuguay