symfony-forms

Dynamic ChoiceType (select2 + AJAX)

拈花ヽ惹草 提交于 2019-12-11 17:59:28
问题 I need a form field to choose from thousands of entities, so a dynamic choice system like select2 (with AJAX) is perfectly suited. My AJAX endpoint works fine, but the custom form type does not work: class Select2AjaxDataCategoryType extends AbstractType { /** * @var EntityManagerInterface */ private $entityManager; /** * @var RouterInterface */ private $router; public function __construct(EntityManagerInterface $entityManager, RouterInterface $router) { $this->entityManager = $entityManager;

symfony - embeddedForm - multiple checkboxes

半城伤御伤魂 提交于 2019-12-11 17:52:29
问题 I have article admin module and a tag module Tags are simply a single tag per row item What I'd like to do is to embed the list of all the tags (as checkboxes) into my article module Could I do this with embedded forms? EDIT: This is my schema: article: id: ~ title: { type: VARCHAR, size: '255', required: true } tags: { type: VARCHAR, size: '500' } created_at: { type: TIMESTAMP, required: true } updated_at: { type: TIMESTAMP, required: true } tag: id: ~ tag: { type: VARCHAR, size: '500',

Embedded forms in symfony 1.4 not saving properly

寵の児 提交于 2019-12-11 14:02:06
问题 I have the following model: WebPromocion: connection: doctrine tableName: WebPromocion columns: id: type: integer(4) fixed: false unsigned: true primary: true autoincrement: true nombre: type: string(100) fixed: false unsigned: false primary: false notnull: true autoincrement: false foto: type: integer(4) fixed: false unsigned: true primary: false notnull: true autoincrement: false flyer: type: integer(4) fixed: false unsigned: true primary: false notnull: true autoincrement: false desde:

Symfony - How to pass related entity data to entity field's choices

给你一囗甜甜゛ 提交于 2019-12-11 12:07:25
问题 Good day everyone I have Product entity that related to ProductType entity with many-to-one relation I have the custom ProductsType field based on 'entity' field type: class ProductsType extends AbstractType { /** * @param OptionsResolverInterface $resolver */ public function setDefaultOptions(OptionsResolverInterface $resolver) { $resolver->setDefaults( [ 'label' => 'oq.company.interest.label', 'class' => 'OQReferenceBundle:Product', 'required' => false, 'expanded' => true, 'multiple' =>

Removing table headers from embedRelation()

半世苍凉 提交于 2019-12-11 11:07:22
问题 I have used the embedRelation() to pull another form into the sfGuard user form. It is working correctly, I am just trying to style it to fit into the current form. This pulls the form in: $this->embedRelation('Profile'); but it is adding some extra html elements that I would like to remove: <div class="form_row"> Profile <table> <tbody><tr> <th><label for="sf_guard_user_Profile_department_title">Department</label></th> <td><input type="text" name="sf_guard_user[Profile][department_title]"

Adding a new user field to sfGuard user Admin Form

匆匆过客 提交于 2019-12-11 10:49:10
问题 I am trying to add a custom field to the user form in the sfGuard plugin. I have created the column in the database and added the widgetschema for the field. It is showing up correctly in the form, and when text is added and submitted, it is showing the update was successful. The data inserted into the field is not getting populated in the database though. I am thinking I have to update the model for sfGuard, as it is not aware of the new field. I have tried $ ./symfony doctrine:build-model ,

Form values is empty (not value) after render the widget on a form

穿精又带淫゛_ 提交于 2019-12-11 09:44:44
问题 I've this Form: OrdersType class OrdersType extends AbstractType { public function buildForm(FormBuilderInterface $builder, array $options) { // Others $builder fields goes here if ($this->register_type[0] == "natural") { $builder->add('person', new NaturalPersonType(), array('label' => FALSE)); } elseif ($this->register_type[0] == "legal") { $builder->add('person', new LegalPersonType(), array('label' => FALSE)); } } } PersonType class PersonType extends AbstractType { public function

Symfony | Forms | Self-referencing CollectionType field - ERROR: out of memory

独自空忆成欢 提交于 2019-12-11 08:53:04
问题 First of all we are using Symfony 3.4 . We have a self-referencing field children on an Entity Category . So a category can have category-children and those category-children can have category-children and so on... class Category { /** * @ORM\Column(type="string") */ private $title; /** * @ORM\OneToMany(targetEntity="AcmeBundle\Entity\Category", mappedBy="parent") */ private $children; /** * @ORM\ManyToOne(targetEntity="AcmeBundle\Entity\Category", inversedBy="children") */ private $parent; }

Specify different validation groups for each item of a collection in Symfony 3?

谁说胖子不能爱 提交于 2019-12-11 08:47:33
问题 I have a project entity which has many images, every image has title, imageFile attributes I want the user to be able to add, update and delete images from the project form. The problem is that the projectImage entity validation groups when it is new should be different from when it is being edited. and this is the code ProjectType class ProjectType extends AbstractType { /** * @param FormBuilderInterface $builder * @param array $options */ public function buildForm(FormBuilderInterface

getViewData vs. getNormData and DataTransformers - different results depending on context

被刻印的时光 ゝ 提交于 2019-12-11 06:57:31
问题 I have a form with several fields. Then I bound DataTransformer to the one of them. Transformer works correctly if I get data getViewData and getNormData . But if I issue these methods on whole form, data processed by transformers are completely ignored. In Form data is being overwritten due to the: $childrenIterator = new InheritDataAwareIterator($this->children); $childrenIterator = new \RecursiveIteratorIterator($childrenIterator); $this->config->getDataMapper()->mapFormsToData(