diff --git a/docs/reference/action_list.rst b/docs/reference/action_list.rst index cec5a2e174e..c62ced7f9d7 100644 --- a/docs/reference/action_list.rst +++ b/docs/reference/action_list.rst @@ -177,32 +177,56 @@ Available types and associated options | | catalogue | Translation catalogue. | + +---------------------+-----------------------------------------------------------------------+ | | class | Class path for editable association field. | ++ +---------------------+-----------------------------------------------------------------------+ +| | editable | Yes/No; editable allows to edit directly from the list if authorized. | +-----------+---------------------+-----------------------------------------------------------------------+ | currency | currency (m) | A currency string (EUR or USD for instance). | ++ +---------------------+-----------------------------------------------------------------------+ +| | editable | Yes/No; editable allows to edit directly from the list if authorized. | +-----------+---------------------+-----------------------------------------------------------------------+ | date | format | A format understandable by Twig's ``date`` function. | + +---------------------+-----------------------------------------------------------------------+ | | timezone | Second argument for Twig's ``date`` function | ++ +---------------------+-----------------------------------------------------------------------+ +| | editable | Yes/No; editable allows to edit directly from the list if authorized. | ++-----------+---------------------+-----------------------------------------------------------------------+ +| time | format | A format understandable by Twig's ``date`` function. | ++ +---------------------+-----------------------------------------------------------------------+ +| | timezone | Second argument for Twig's ``date`` function | +-----------+---------------------+-----------------------------------------------------------------------+ | datetime | format | A format understandable by Twig's ``date`` function. | + +---------------------+-----------------------------------------------------------------------+ | | timezone | Second argument for Twig's ``date`` function | ++ +---------------------+-----------------------------------------------------------------------+ +| | editable | Yes/No; editable allows to edit directly from the list if authorized. | ++-----------+---------------------+-----------------------------------------------------------------------+ +| time | format | A format understandable by Twig's ``date`` function. | ++ +---------------------+-----------------------------------------------------------------------+ +| | timezone | Second argument for Twig's ``date`` function | +-----------+---------------------+-----------------------------------------------------------------------+ | email | as_string | Renders the email as string, without any link. | + +---------------------+-----------------------------------------------------------------------+ | | subject | Add subject parameter to email link. | + +---------------------+-----------------------------------------------------------------------+ | | body | Add body parameter to email link. | ++ +---------------------+-----------------------------------------------------------------------+ +| | editable | Yes/No; editable allows to edit directly from the list if authorized. | +-----------+---------------------+-----------------------------------------------------------------------+ | percent | | Renders value as a percentage. | ++ +---------------------+-----------------------------------------------------------------------+ +| | editable | Yes/No; editable allows to edit directly from the list if authorized. | +-----------+---------------------+-----------------------------------------------------------------------+ | string | | Renders a string. | ++ +---------------------+-----------------------------------------------------------------------+ +| | editable | Yes/No; editable allows to edit directly from the list if authorized. | +-----------+---------------------+-----------------------------------------------------------------------+ | text | | See 'string' | +-----------+---------------------+-----------------------------------------------------------------------+ -| html | | Renders string as html | +| textarea | | See 'string' | +-----------+---------------------+-----------------------------------------------------------------------+ -| time | | Renders a datetime's time with format ``H:i:s``. | +| html | | Renders string as html | ++ +---------------------+-----------------------------------------------------------------------+ +| | editable | Yes/No; editable allows to edit directly from the list if authorized. | +-----------+---------------------+-----------------------------------------------------------------------+ | trans | catalogue | Translates the value with catalogue ``catalogue`` if defined. | +-----------+---------------------+-----------------------------------------------------------------------+ @@ -215,6 +239,22 @@ Available types and associated options | | parameters | Route parameters | + +---------------------+-----------------------------------------------------------------------+ | | hide_protocol | Hide http:// or https:// (default: false) | ++ +---------------------+-----------------------------------------------------------------------+ +| | editable | Yes/No; editable allows to edit directly from the list if authorized. | ++-----------+---------------------+-----------------------------------------------------------------------+ +| integer | | Renders a integer. | ++ +---------------------+-----------------------------------------------------------------------+ +| | editable | Yes/No; editable allows to edit directly from the list if authorized. | ++-----------+---------------------+-----------------------------------------------------------------------+ +| smallint | | See 'integer' | ++-----------+---------------------+-----------------------------------------------------------------------+ +| bigint | | See 'integer' | ++-----------+---------------------+-----------------------------------------------------------------------+ +| bigint | | See 'integer' | ++-----------+---------------------+-----------------------------------------------------------------------+ +| decimal | | Renders a decimal. | ++ +---------------------+-----------------------------------------------------------------------+ +| | editable | Yes/No; editable allows to edit directly from the list if authorized. | +-----------+---------------------+-----------------------------------------------------------------------+ If you have the SonataDoctrineORMAdminBundle installed, you have access diff --git a/src/Resources/config/twig.xml b/src/Resources/config/twig.xml index cd9431fa5b5..99eca264217 100644 --- a/src/Resources/config/twig.xml +++ b/src/Resources/config/twig.xml @@ -17,6 +17,7 @@ number url date + datetime diff --git a/src/Resources/views/CRUD/base_list_field.html.twig b/src/Resources/views/CRUD/base_list_field.html.twig index 5f9eef3c9c1..169fd2d80a1 100644 --- a/src/Resources/views/CRUD/base_list_field.html.twig +++ b/src/Resources/views/CRUD/base_list_field.html.twig @@ -55,7 +55,11 @@ file that was distributed with this source code. ) %} {% if field_description.type == constant('Sonata\\AdminBundle\\Templating\\TemplateRegistry::TYPE_DATE') and value is not empty %} - {% set data_value = value.format('Y-m-d') %} + {# it is a x-editable format https://vitalets.github.io/x-editable/docs.html#date #} + {% set data_value = value|date('Y-m-d') %} + {% elseif field_description.type == constant('Sonata\\AdminBundle\\Templating\\TemplateRegistry::TYPE_DATETIME') and value is not empty %} + {# it is a x-editable format https://vitalets.github.io/x-editable/docs.html#datetime #} + {% set data_value = value|date('Y-m-d H:i') %} {% elseif field_description.type == constant('Sonata\\AdminBundle\\Templating\\TemplateRegistry::TYPE_BOOLEAN') and value is empty %} {% set data_value = 0 %} {% elseif value is iterable %} @@ -70,6 +74,11 @@ file that was distributed with this source code. {% if field_description.label is not same as(false) %} data-title="{{ field_description.label|trans({}, field_description.translationDomain) }}" {% endif %} + {% if field_description.type == constant('Sonata\\AdminBundle\\Templating\\TemplateRegistry::TYPE_DATE') %} + data-format="yyyy-mm-dd" + {% elseif field_description.type == constant('Sonata\\AdminBundle\\Templating\\TemplateRegistry::TYPE_DATETIME') %} + data-format="yyyy-mm-dd hh:ii" + {% endif %} data-pk="{{ admin.id(object) }}" data-url="{{ url }}" {% endblock %}> {{ block('field') }}