Symfony2 Form component that makes dealing with forms easy.
Questions tagged [symfony2-forms]
22 questions
16
votes
3 answers
Allow the addition of new values to a ChoiceType Field
I use Form Component and have a ChoiceType field on the form which is rendered to a select field.
On the client-side I use select2 plugin which initializes a select with tags: true allowing the addition of new values to it.
But if I add a new value…

Vasily
- 1,858
- 1
- 21
- 34
6
votes
3 answers
How to disable one transformer validation error "dynamically" in Symfony2
I have a form with many fields and validation groups, these fields contain some view data transformers too.
I need suppress the validation form partially (Groups based on the Submitted Data):
use AppBundle\Entity\Client;
use…

yceruto
- 9,230
- 5
- 38
- 65
4
votes
3 answers
Silex FormServiceProvider could not load type "form" when using Symfony3 Components
When trying to build a form I receive this error:
InvalidArgumentException in FormRegistry.php line 87: Could not load
type "form"
I've registered the FormServiceProvider, TranslationServicerProvider, and ValidatorServiceProvider.
Here is the…

bestattendance
- 26,382
- 5
- 25
- 24
4
votes
3 answers
Two buttons in a row (Bootstrap form theme for Symfony2)
I'm using the Bootstrap form theme for Symfony2 (bootstrap_3_horizontal_layout.html.twig):
I've added two buttons on a form:
$builder
// some code here ...
->add('save', 'submit', ['label' => 'save'])
->add('cancel', 'submit', ['label'…

Vasily
- 1,858
- 1
- 21
- 34
2
votes
1 answer
Symfony2 - define collection type form as a service
I would like to use a service in my form PRE_SET_DATA event listener. Now this form is embedded into another form type as CollectionType.
class ChildType extends AbstractType
{
private $entitymanager;
public function…
user3076049
2
votes
3 answers
Extend Doctrine2 form EntityType
I'm looking for a way to extend Symfony 2 EntityType
Symfony\Bridge\Doctrine\Form\Type\EntityType
as in a new type extending this one, not creating a FormTypeExtension - and I can't figure it out. Does anyone know any proper way to do that?
I've…

pzaj
- 1,062
- 1
- 17
- 37
2
votes
0 answers
Symfony - Dynamically add form validation based on underlying data
I have an entity class quote that has a field amount and this field should be less than a dynamic value which is set in the controller's newAction.
I am adding the amount field in the formtype class and My buildForm method in it is as follows
public…

user972616
- 1,324
- 3
- 18
- 38
1
vote
2 answers
Symfony - CSRF token is invalid - FosRestBundle
I'm using Symfony and FosRestBundle.
When I want to simply test my rest api, I got this :
The CSRF token is invalid. Please try to resubmit the form.
/**
* @example ["titre", "short description", "description", "2016-10-10", 200, "with…

Xero
- 3,951
- 4
- 41
- 73
1
vote
1 answer
Symfony display form errors from validation method
Because i am used to Laravel I tried validating forms within a seperate method. But I don't know how to redirect back and display the errors. The main problem is displaying the errors. Best case scenario would be if i can set the errors from the…

finalgamer
- 13
- 2
1
vote
1 answer
Is there a way to force a form bind in Symfony2?
I have a form type
class LoginFacebookType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('access_token', 'text', array("constraints" => array(
…

Pipe
- 2,379
- 2
- 19
- 33
1
vote
1 answer
Symfony one to one Bidirectional embedded forms
I have one-to-one bidirectional relationship between user and
institute. Each user can own an institute at a time and each institute
is owned by one user at a time. What i wanted to do is i have
institutes data in my institute table, now i want to…

Muhammad Taqi
- 5,356
- 7
- 36
- 61
1
vote
2 answers
Symfony2 Catchable Fatal Error: set method
I try to write on db but i receive this error when i write this code:
public function createAction(Request $request)
{
$id_user = $request->get('id_user');
var_dump($id_user);
$prova = intval($id_user);
$entity = new…

Luca M
- 371
- 3
- 18
1
vote
1 answer
Prepopulate form fields
I have a user creation form (on top of Symfony Form component), it's used on some different pages and is loaded via AJAX.
An initial request contains information we already know about a user-to-be, e.g. if form is loaded from a manager creation…

Vasily
- 1,858
- 1
- 21
- 34
0
votes
1 answer
Symfony2: The form's view data is expected to be an instance of entity but is array
There are two actions (new and edit) that use the same form. The form shall create a new entity (MyBundle\Entity\Project) or edit an existing one. Each project can be assigned to one team (MyBundle\Entity\Team), one team can hold multiple…

cnmicha
- 164
- 1
- 3
- 12
0
votes
0 answers
Symfony2 form getting value array
I have a small problem while i'm trying to read data from my form
#ProblemePersonneType.php#
->add("enfants",'choice', array('choices' => array( 'enfant1'=>"CAF",
'enfant2'=>"Scolarisé",
…