-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
getFormFieldTypes() does not merge settings in frontend forms #3219
Comments
Yes, that is kind of what is expected as it's not a merge, but just adding missing keys (defaults) to the main level. In most cases merging would be wrong anyway, but I think that for validate it should do an exception. |
Needs a fix in |
Should be fixed in toolbox. |
What is the target milestone/version? |
Next version, it'll be out today. |
This still does not work for me with 1.7.12. And yes, I've done a composer update. |
I tested adding the field into a page. I'm getting this error when trying to enter invalid value:
So the validation surely works, at least in admin and with flex objects. |
Seems not to be the case for frontend forms. I am using this form field template to test (i've manually modified the max to 10, but the code should limit it to 5) {% extends "forms/field.html.twig" %}
{% set originalValue = value %}
{% block input %}
<fieldset class="rating-input {{ form_field_wrapper_classes }} {{ field.wrapper_classes }}">
{# It is important to count from max to min, as this is required by the css. #}
{% for i in 10..field.validate.min|default(1) %}
{% set id = field.id|default(field.name) ~ '-star' ~ i %}
<input type="radio"
value="{{ i|e }}"
id="{{ id|e }}"
name="{{ (scope ~ field.name)|fieldName }}"
class="{{ form_field_rating_classes }} {{ field.classes }}"
{% if i == value %}checked="checked" {% endif %}
{% if field.disabled or isDisabledToggleable %}disabled="disabled"{% endif %}
{% if required %}required="required"{% endif %}
{% if field.tabindex %}tabindex="{{ field.tabindex }}"{% endif %}
min="{{ field.validate.min|default(1) }}"
max="{{ field.validate.max|default(5) }}"
step="{{ field.validate.step|default(1) }}"
/>
<label for="{{ id|e }}" title="{{ field.titles[i]|t|default(i ~ ' ' ~ 'PLUGIN_RATINGS.STARS'|t) }}"></label>
{% endfor %}
</fieldset>
{% endblock %} And you must make sure when adding the form, you must set it to required. Now I got the following yaml file: - name: stars
type: rating
label: PLUGIN_RATINGS.RATING_LABEL
validate:
required: true Maybe the problem only occurs because I've added the form via code? Steps to reproduce:
Ready to test example: |
I reopened the issue so I won't forget it. |
Imagine a plugin code like this:
Now I got the following yaml file:
Because I specified
validate.required: true
all other settings set bygetFormFieldTypes()
are now lost. I need to repeat them again, which is more error prone:The text was updated successfully, but these errors were encountered: