Closed rpostolov closed 10 years ago
Hi @rpostolov
This is because afe_single_upload
only allows the false
value for the required
option... but I don't really remember why...
@loostro any remembers on that point?
The change was introduced along with update of blueimp libraries. I don't remember exacly why it was introduced, but looking at the commit it seems intentional see commit changes.
@rpostolov you can edit in your /vendor
dir the Form class and test if allowing true does not cause any issues
I don't remember why this has been introduced... but if I'm not wrong, there was a case where putting "true" could result in an issue... I have a project using it, I'm going to test it.
Ok thanks let me know the result of the test and if you have a solution let know it :)
Have a nice day !
Hi @rpostolov ,
Ok, I've made some additional tests, and I think I know why this field has been forced to false
. Let me try to explain you what's happening here.
Actually, one important thing to remember is that the required
option doesn't make any validation on server-side. It's just a helper for HTML5: http://symfony.com/doc/current/book/forms.html (look for "The required option" block).
So the thing is, in its current implementation, if we had the required="required"
attribute and the user doesn't select any file, HTML5 error render is not well handled. Actually, because of the JS component, the file itself is hidden. So the "HTML5 required field popin" is displayed "anywhere". But because required
doesn't prevent you to make server-side checks, we simply force the required option to false (and you so need to make your Validation test on your entity).
Theorically, we should be able to handle the required=true
option... But this is just for HTML5 rendering on client site.
A PR is so welcome to allow the required option to add some validation on client side (with a onsubmit handler on the form if option required
is true).
But keep in mind that this should not been blocking knowing that it doesn't prevent you for any Server Side check.
Does it make sense for you?
One more time, PR is welcome :) Do not hesitate to handle it.
I close the issue because it should better be in the AvocodeFormExtensionsBundle
Thanks,
Hi @sescandell thanks a lot for your research and explanations. I understand, i will try to find a solution. And of course i will make a PR :)
Have a nice day !
Hi,
I'm sorry if maybe this issue doesn't belong here but i'm using avocod with admingenerator and both are linked so...
I try to make this field riquiered but i hav this error :
The option "required" has the value "1", but is expected to be one of ""
Here is my code in ApplyAdmingenerator.yml
Thanks