Kaynağa Gözat

Add more type and documentation

Thomas Rabaix 13 yıl önce
ebeveyn
işleme
c3452c97f8

+ 27 - 0
Resources/doc/reference/field_types.rst

@@ -0,0 +1,27 @@
+Field Types
+===========
+
+List and Show Actions
+---------------------
+
+There are many field types that can be used in the list action or show action :
+
+* array: display value from an array
+* boolean: display a green or red picture depend on the boolean value
+* date: display a formatted date
+* datetime: display a formatted date
+* text: display a text
+* trans: translate the value with a provided ``catalogue`` option
+* string: display a text
+* decimal: display a number
+* currency: display a number with a provided ``currency`` option
+* percent: display a percentage
+
+.. note::
+
+    If the ``SonataIntlBundle`` is installed in the project some template types
+    will be changed to use localized information.
+
+
+More types might be provided depends on the persistency layer defined. Please refer to there
+related documentations.

+ 16 - 0
Resources/views/CRUD/list_currency.html.twig

@@ -0,0 +1,16 @@
+{#
+
+This file is part of the Sonata package.
+
+(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
+
+For the full copyright and license information, please view the LICENSE
+file that was distributed with this source code.
+
+#}
+
+{% extends 'SonataAdminBundle:CRUD:base_list_field.html.twig' %}
+
+{% block field %}
+    {{ field_description.options.currency }} {{ value }}
+{% endblock %}

+ 17 - 0
Resources/views/CRUD/list_percent.html.twig

@@ -0,0 +1,17 @@
+{#
+
+This file is part of the Sonata package.
+
+(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
+
+For the full copyright and license information, please view the LICENSE
+file that was distributed with this source code.
+
+#}
+
+{% extends 'SonataAdminBundle:CRUD:base_list_field.html.twig' %}
+
+{% block field %}
+    {% set value = value * 100 %}
+    {{ value }} %
+{% endblock %}