New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The UrlType renders an <input type = "text" /> instead of an <input type = "url" /> #30635
Comments
Which Symfony version do you use? How is your form configured? |
Related to #29926? |
Hi. Sorry for the delay when responding. This is the field: $builder->add('url', UrlType::class, [
'default_protocol' => 'https',
'required' => false,
'attr' => [
'class' => 'form-control',
'placeholder' => 'https://domain.com',
'pattern' => '^(http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/)?[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$'
]
]) As you can see I had to add a pattern to validate the url. This is the HTML: <input type="text" name="entity[url]" class="form-control" placeholder="https://domain.com" pattern="^(http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/)?[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$" inputmode="url"> |
#29926 is released in 3.4.22, looks like you received a bugfix 😅 (because of default_protocol the input should allow for protocol-less values, hence type text in this case) |
As @ro0NL explained this is the expected behaviour. So I'm going to close here. Thank you for understanding. |
As I understand, if I remove the default protocol option should I render the input to url type? |
Edit: The option needs to be set to |
Well no, it continues to be rendered in the same way. |
Can you create a example application that allows to reproduce your problem? |
I have created a project but I have not been able to prove it. Use the crud generator and do not open the form page. Initially he sent me the following error "Maximum function nesting level of '256' reached, aborting! stackoverflow". Afterwards no longer. |
When adding the $builder->add('url', CoreUrlType::class, ['default_protocol' => null]); |
Great. Ok thanks. |
Symfony version(s) affected: 3.4.22
Description
The Url Type renders an instead of an so this field is not validated in Google Chrome.
The text was updated successfully, but these errors were encountered: