我正在使用表单/键入FormBuilder来设置表单。但是,如何才能将数据从Repository转换为Form Type呢?下面的代码不起作用。
Using a Custom Query for the Entities
If you need to specify a custom query to use when fetching the entities (e.g. you only want to return some entities, or need to order them), use the query_builder option. The easiest way t
如何在Symfony中获取表单生成器中的字段值。我有两个下拉的形式,我想应该在Dropdown2的相关选项,在Dropdown1的基础上,在页面打开。
这是我的表格
use Symfony\Component\Form\FormEvents;
use Symfony\Component\Form\Event\DataEvent;
use C2Educate\ToolsBundle\Entity\Students;
public function buildForm(FormBuilder $builder, array $options) {
领域1:
$builder->add(
我在Symfony2 Beta3中使用类表单,如下所示:
namespace Partners\FrontendBundle\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilder;
class ConfigForm extends AbstractType
{
public function buildForm(FormBuilder $builder, array $options)
{
$builder->add('no_c
这是我的文件:
<?php
namespace EM\ExpensesBundle\Entity;
use Symfony\Component\Form\FormBuilder;
use Symfony\Component\Form\AbstractType;
class ChooseCatType extends AbstractType
{
public function buildForm(FormBuilder $builder, array $options)
{
$builder->add('name', '
我在我的项目中做了类似的事情:
use Doctrine\ORM\EntityRepository;
class ArticlesType extends AbstractType {
static function statusFilter(EntityRepository $er) {
return $er->createQueryBuilder('x')->where('x.status = 1');
}
public function buildForm(FormBuilder $builder,
我的表单基于自引用实体(类别具有父类别)
对于parent字段,我希望根据动作名称使用不同的query_builder函数。当操作为update时,parent字段(下拉列表)包含除已编辑类别外的所有类别。这是很好的工作。但是,当操作为Create new时,父表单域只包含主类别的值(在我的例子中是null )。这是类别窗体类CategoryType类:
namespace Dimas\CatalogBundle\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterf
我在我的项目中使用了gregwarCaptchaBundle,我得到了以下错误消息:Could not load type "Symfony\Component\Form\Extension\Core\Type\TextType"
详细信息:
at FormRegistry ->getType ('Symfony\Component\Form\Extension\Core\Type\TextType')
in vendor/symfony/symfony/src/Symfony/Component/Form/FormRegistry.php at lin
我有一张表格,里面有很多的复选框。表单保存得很好(我检查了数据库以确保),但是复选框并没有与数据库一致。
有什么特别的事情我需要做才能让复选框被检查吗?
以下是我的表单定义:
<?php
namespace VNN\PressboxBundle\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilder;
class PreferencesSportsICareAboutType extends AbstractType
{
public function bui
我正在努力寻找关于如何创建此表单的最佳实践,我有一个实体,我希望创建一个表单,该表单将列出所有实体以及每个实体的复选框,用户可以使用复选框选择多个实体并将一个操作应用于所有选定的实体,如下所示:
-Actions
--- Remove
--- Disable
--- Enable
# , Title , Desc
[] , title1 , This is a desc one
[] , Title2 , this is a desc two
[] , Title3 , this is a desc three
//[] is a checkbox
在不使用Fo
当我访问我的浏览器时,我得到的是:
Fatal error: Declaration of Ecs\CrmBundle\Form\Parts\DepartmentSelectionType::getDefaultOptions() must be compatible with Symfony\Component\Form\FormTypeInterface::getDefaultOptions() in C:\wamp\www\crm\src\Ecs\CrmBundle\Form\Parts\DepartmentSelectionType.php on line 41
并且它所引用的文件位于
实际上,我正在学习Symfony2,我有一个问题。我在电影和演员之间有许多关系。
我已经创建了一个表单来创建一部新电影。在这个表单中,我选择了一个输入来选择参与者,但是当我选择了许多参与者时,表单生成了一个错误“this value not be not”。当我在actor类中删除我的断言时,我没有这个错误。为什么我的表单要检查actor类中的断言?
/*
* MOVIE CLASS
*
*/
class Movie
{
//...
/**