Tagged Questions
0
votes
1answer
11 views
Symfony 2 collection unique elements constraint, mapping errors to children
I have a formtype with single field: collection, containing unspecified number of anonymous selects. Is there a way to check if there are duplicate choices using builtin constraints? In case I have to ...
-2
votes
0answers
11 views
symfony2 how to use standard validators in a custom validator [on hold]
I vant to run a NotBlank and an Image validators in my custom validator on the $value. How can I call them in validate method of my custom validator?
0
votes
0answers
17 views
symfony2 validate one of two form fields is not blank
what's the simplest way to add a validator which checks that one of two form fields is not blank?
$builder
...
->add('file', 'file', array(
'constraints' => ...
0
votes
0answers
25 views
Symfony Image Upload Validator Not Working
I've got a Silex application with a file upload form that includes an Image validator. The other field validators appear to be working (i.e. I can cause the form submit to invalidate), but the file ...
0
votes
0answers
31 views
Symfony 2 form cascading validation
I have a form in symfony 2 like:
$form = $this->createFormBuilder();
$form
->add('subscription', 'entity', array(
'class' => ...
1
vote
1answer
16 views
Validating exceptions inside methods with Symfony2 and Doctrine
I'm new in Symfony2, so I'm pretty sure this is basic but I can't find the answer on the web,
I have an entity persisted in MySql through Doctrine, all of its properties have their own validation ...
0
votes
1answer
27 views
csrf_token symfony2 validate
I'm new working with symfony2 and I have a problem when I try to validate the csrf token in a custom form, my question is ¿how can I validate the csrf token in the controller?
This is my code in my ...
0
votes
0answers
17 views
symfony2 validation is disabled if by_reference is false / on true it works
I dont understand whats the problem with this "by_reference" option...
The problem is that the "form->isValid()" said "YES" but the emails collection issnt valid.
If i set the by_reference to true ...
1
vote
1answer
36 views
Symfony2 Asset GreaterThan didn't work
I have an issue actually.
The property "Quantity" in Invetory entity should not be negative.
So I try to use the GreaterThan or GreaterThanOrEqual assert in my entity declaration.
In fact, I can ...
0
votes
2answers
52 views
Symfony forms - Expected argument of type “string”, “DateTime” given
I get this error message:
"Expected argument of type "string", "DateTime" given"
This is the code of my form in symfony
$builder->add('dateOfBirth', 'datetime', [
'widget' => ...
0
votes
1answer
13 views
Symfony2 Using Entity in Validation Constraint
I'm trying to validate one unique field using Symfony validation engine. I've created validation constraints and everything works fine but I want to have validated entity (or POST data) in my ...
0
votes
0answers
26 views
Dynamic choices causes “This value is not valid.” in Symfony2 Forms
So I have three select elements, one for countries, the second for states and the third for cities. Since second and third select options are built dinamically so I use DataTransformers to work with ...
0
votes
1answer
39 views
Symfony 2.3 validating form with handleRequest is insanely slow
Im submitting a form with a lot of fields and trying to validate it with handleRequest($request) as its shown in the symfony documentation.
My entity is very big and has a lot of relations with other ...
0
votes
1answer
28 views
Symfony entity annotations: constraints vs field types
The Symfony docs list a number of field types that can be used when rendering forms. However, the docs also specify constrains that can be used for form validation. Can these two concepts be combined ...
3
votes
1answer
29 views
How can I define a set of values for the NotEqualTo constraint?
When using the NotEqualTo validator constraint, I want to define more than one value.
This is how it is used for one value:
# src/SocialBundle/Resources/config/validation.yml
...
1
vote
1answer
41 views
How to pass parameter to translated validation error message
In Symfony2, you can translate your validation error messages:
Validation File
# src/Acme/BlogBundle/Resources/config/validation.yml
Acme\BlogBundle\Entity\Author:
properties:
name:
...
0
votes
0answers
17 views
Error with Validation Symfony2 MaxSize
I have a entity with anntotations to validate the file uploaded. In my php.ini max_size is stablished in 8MB and max_upload_size also in 8MB.
@Assert\File(
maxSize = "8M",
...
3
votes
3answers
35 views
REST form validation in symfony 2 - how to test post
The form is never valid, but $form->getErrors() gives no error.
Since its gonna be a REST Api i test it with DEV HTTP client
test data is
header:
Content-Type:application/json
body:
...
0
votes
1answer
23 views
Symfony2 ignores form validation of collection
i have a problem with Symfony2 and the validation of an email addresses collection.
Entity\User
/**
* User
*
* @ORM\Table()
* @ORM\Entity
*/
class User
{
/**
* @ORM\Id
* ...
0
votes
0answers
18 views
Symfony2 Set form data to Auth User Class
Im use this form code;
public function accountAction(Request $request)
{
$user = $this->getUser();
$account_form = $this->createForm(new ...
0
votes
1answer
29 views
symfony2 image type constraint validation
I know that the prefered way of uploading files is via Doctrine as explained in the book, but i need to save image data in an xml file and I also like constraint validator. Not much code has to be ...
-1
votes
2answers
31 views
Symfony2 Constraints\email not found
I installed a email validator for a newsletter form in Symfony2. Locally everything works fine, but if I upload the whole folder to my webhosting i get the following error message:
Fatal error: Class ...
0
votes
1answer
23 views
Translate symfony validation messages
in my project I using the locale translation.
I have two files in ..Resources/translation
=>
messages.sk.yml
validators.sk.yml
validators.sk.yml
=>
validation:
error: 'here is error message'
...
1
vote
2answers
48 views
Symfony2: validation constraint ignored when submitting form and with multiple validation groups
Problem:
The Length constraint is ignored when submitting my form.
Entity:
/**
* @Assert\Length(min = "6")
* @Assert\NotBlank(groups={"registro"})
*/
private $password;
FormType:
public ...
0
votes
1answer
122 views
Symfony 2 - form validation - if user Record exists in database
I fighting with form validation.. (why easy thing are so difficult and conplicated in SF2 ? :|)
I have validator:
/Acme/Crud/Validator/Constraints/isNewsInDB.php
namespace ...
1
vote
0answers
15 views
Translating Custom Validator messages with parameters
I have symfony2 custom validator with definition:
// Nip.php
use Symfony\Component\Validator\Constraint;
/**
* @Annotation
*/
class Nip extends Constraint
{
public $message = 'This value ...
0
votes
1answer
25 views
How to redirect to form with errors if not valid in Symfony2?
I don't know how to redirect errors to a form if it's not valid with Symfony2?
So I use the Assert in my entity like that:
/**
* @ORM\Column(type="string", length=255, nullable=false)
* ...
2
votes
3answers
33 views
Symfony custom form with validation
I created a simple form using official symfony documentation:
public function newAction(Request $request)
{
// create a task and give it some dummy data for this example
$task = new Task();
...
1
vote
0answers
22 views
Using Symfony2 UserPassword validator in form type
Im trying to use a specific validator in a form.
That form is for an user to redefine his password, he must also enter his current password.
For that I use a built in validator from symfony
in my ...
1
vote
1answer
27 views
How to handle a form from another controller in Symfony2?
I have 2 separate controllers Controller1:somethingAction and Controller2:processForm.
In somethingAction I create a form and set its action (url) to processForm's url. When the form in ...
1
vote
2answers
30 views
Symfony2: How to write a custom validator that validates a combination of 3 different properties at once?
I want to create a validator that validates a combination of 3 object properties.
I need to check package-size so I have to sum width, height and length.
I can't access height & length if I map ...
0
votes
0answers
22 views
Manually Validating Symfony Form with JsFormValidatorBundle
I'm having a little issue with the Symfony JsFormValidatorBundle
https://github.com/formapro/JsFormValidatorBundle
I want to have 2 options
1) Validate and submit the form manually (e.g. don't ...
0
votes
1answer
35 views
Combine all NotBlank error messages in Symfony2
I'm trying to combine all NotBlank error messages into one.
If the error array contains at least 1 error that is a NotBlank type, I want it to display only one message like "Please fill in all ...
0
votes
1answer
39 views
Symfony 2 validation
i have a question regarding symfony 2 validation via an Entity and a validation configuration file. Here is the explanation of the problem.
I have an entity for the users account settings which has 5 ...
2
votes
1answer
33 views
Select entity by property / User by username
i have the FOSUserBundle installed.
Now i would like to select all users via <select /> box.
For example i have...
<?php
// [...]
class ProfileType extends AbstractType
{
public ...
0
votes
0answers
25 views
Symfony 2.3.7 Add Validation to Dynamically created a form with select and textarea fields
I'm dinamically creating a form that has a pair SELECT and TEXTAREA FIELDS. After these, I have a submit button.
Every SELECT (with values from 1 to 10) is required. If SELECT has a value min than 7 ...
1
vote
1answer
36 views
Constraint Validator validates Entity before Entity is ready in Symfony 2
My Symfony2 (2.4.2) application has a form, and an entity which I have set some validation constraints on some fields. One of the entity's variables is an array which should not be blank.
The form ...
0
votes
0answers
31 views
Symfony2 Form Field data_class Validation doesnt works
I've this type with the following validation:
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('name', null, array(
...
0
votes
1answer
34 views
Validate username in Symfony2 form
I have a form in Symfony2 where an Admin have to write the username of another user.
Is it possible to check before to send the form, if the username exist in my database? I use doctrine.
Thanks!
1
vote
1answer
55 views
Checkbox entity field type return empty value
I have a form which list the possible answers of a quiz into a choice field (checkboxes)
Problem is when i check some boxes and submit my form i get an empty result instead of get checkboxes ...
0
votes
1answer
49 views
Symfony 2.3: Validate entities inside collection field
I'm trying to validate entities inside a collection field with validation.yml schema but it doesn't work. I've tried it in two ways.
The first approach was with Collection constraint, but collection ...
1
vote
1answer
32 views
Symfony - UniqueEntity validation fails with exception “addConstraint() must be an instance of Symfony\Component\Validator\Constraint, array given”
When I am trying to validate my user entity form after posting I am getting a
ContextErrorException: Catchable Fatal Error: Argument 1 passed to ...
0
votes
0answers
38 views
Symfony 2 custom validator on field
I made my custom date range validator, and I'm using it on date properties of my entity..
Though, when I get an error it's attached to the form and not to the field.
So I can't display errors with ...
0
votes
0answers
36 views
The schemaOrCallable argument has to be a valid path to XSD file or callable
I'm having some problems with my Symfony2 site. I don't know what I have changed last that triggered this exception and my search was not that successful.
The schemaOrCallable argument has to be a ...
1
vote
1answer
23 views
symfony2 form validation: form field name “not valid” error
I created a Form in Symfony2, with the field "name" set to the type "text"... But for some reason, I can't use any spaces in this field... I get the following error:
form type name ("") is not valid
...
0
votes
1answer
37 views
Symfony2 - Adding validation rule dynamically in controller
Currently I am using validation.yml for validations. Everything works fine.
But I need to add a validation rule on a specific condition.
I have a selectbox to select a type, and a textbox to enter ...
0
votes
1answer
26 views
GroupSequenceProvider on Child form entities in Symfony2
I have a parent form and a child which is of type collection, which can have adds/removes.
I need the GroupSequenceProviderInterface on both the parent and the child entities, because my validation ...
0
votes
1answer
54 views
Symfony2 FOSRestBundle timestamp validation fails
I'm trying to send a post request including two timestamps to my REST api.
The problem is that the timestamps are marked as invalid. "This value is not valid."
What am I doing wrong?
This is the ...
0
votes
1answer
32 views
Symfony2 Form validation dependency between form_types in one form
In my symfony2 project I created a new FormType which is called "ChoiceAndOrTextType" which is a list of choices (checkboxes) but the user can also check the "others" option and write his answer into ...
1
vote
1answer
238 views
Bootstrap 3 JQuery Validation not working
I am working on Symfony2 project and have used bootstrap 3.0.2. I have used jquery validation 1.9.0 plugin for login validation.
I want to do somethi like thisFiddle
is worked in core php but in ...