Closed peter-gribanov closed 4 years ago
Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
Yes. This issue is still relevant. I still haven’t received any feedback.
I think using 'choice'
is deprecated. Please use the type name like you would on a regular Symfony. That will help us understand what type you are actually using and debug further (I never remember what 'choice'
translates to in the end)
@greg0ire see your documentation https://symfony.com/doc/master/bundles/SonataAdminBundle/reference/action_list.html#available-types-and-associated-options
@greg0ire using Symfony\Component\Form\Extension\Core\Type\ChoiceType
does not affect the result
:thinking: We should probably update the docs, using the name is deprecated.
@greg0ire using Symfony\Component\Form\Extension\Core\Type\ChoiceType does not affect the result
But it does affect my understanding… I thought you were using a Sonata type, but this is a native form type. Is the bug that the native HTML5 required attribute is not rendered?
And why do you say
Need add a required option to oblige to select a value from the list of valid values.
You are using that option in your example
I have taken a look at this and I think we are mixing things. This example is talking about the list, as @peter-gribanov said, the types available are in the docs. This has nothing to do with Symfony Type forms, but because this issue is about editable
is a little bit confusing.
@greg0ire using
Symfony\Component\Form\Extension\Core\Type\ChoiceType
does not affect the result
I think this won't work because as I said this is about the list and editable
uses this mapping.
That being said, the permission you already have in you entity is also one of the Permission::change()
returns? maybe this is because it is not in that list and it does not select any.
All is well. I understood. The problem is on my side. Sorry.
The problem is that i use ValueObject and when casting object to a string, the label is returned, not the value.
Solution for me:
{# @Frontend/Testimonial/admin/list_permission.html.twig #}
{% extends admin.getTemplate('base_list_field') %}
{% set is_editable =
field_description.options.editable is defined and
field_description.options.editable and
admin.hasAccess('edit', object)
%}
{% set x_editable_type = field_description.type | sonata_xeditable_type %}
{% block field_span_attributes %}
{%- if is_editable and x_editable_type %}
class="x-editable"
data-type="{{ xEditableType }}"
data-title="{{ field_description.label|trans({}, field_description.translationDomain) }}"
data-pk="{{ admin.id(object) }}"
data-url="{{ url }}"
data-source="{{ field_description | sonata_xeditable_choices | json_encode }}"
{# correct resolve value for x-editable #}
data-value="{% if value.isAwaiting %}approved{% else %}{{ value.value }}{% endif %}"
{%- endif -%}
{% endblock %}
{% block field -%}
{%- set bem_modifier %}
{%- if value.isAwaiting -%}
label-danger
{%- elseif value.isApproved -%}
label-success
{%- else -%}
label-warning
{%- endif -%}
{%- endset -%}
<span class="label {{ bem_modifier }}">{{ value | trans({}, field_description.options.catalogue) }}</span>
{%- endblock %}
Sorry again.
Environment
Sonata packages
Symfony packages
PHP version
Subject
Need add a required option to oblige to select a value from the list of valid values.
Perhaps a related issue #5693.Steps to reproduce
Make entity
Configure field as editable in admin service
Go to admin. Change the permission, but do not select a value
Expected results
It is necessary to separate the case when we can use
NULL
as a value, and when not. In my case,NULL
is not a valid value.Actual results
Click submit and get 500 error because
NULL
comes