Skip to content

Commit

Permalink
register a datetime field type as editable
Browse files Browse the repository at this point in the history
correct documentation

add a time field options in documentation

remove deprecated field types from documentation

datetime field type is not editable

use constants in documentation
  • Loading branch information
peter-gribanov committed Jun 16, 2020
1 parent f807ac1 commit 8261ac2
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 119 deletions.
160 changes: 91 additions & 69 deletions docs/reference/action_list.rst
Original file line number Diff line number Diff line change
Expand Up @@ -147,75 +147,97 @@ Available types and associated options

``(m)`` means that option is mandatory

+-----------+---------------------+-----------------------------------------------------------------------+
| Type | Options | Description |
+===========+=====================+=======================================================================+
| actions | actions | List of available actions |
+ + + +
| | edit | Name of the action (``show``, ``edit``, ``history``, ``delete``, etc) |
+ + + +
| | link_parameters | Route parameters |
+-----------+---------------------+-----------------------------------------------------------------------+
| batch | | Renders a checkbox |
+-----------+---------------------+-----------------------------------------------------------------------+
| select | | Renders a select box |
+-----------+---------------------+-----------------------------------------------------------------------+
| array | | Displays an array |
+-----------+---------------------+-----------------------------------------------------------------------+
| boolean | ajax_hidden | Yes/No; ajax_hidden allows to hide list field during an AJAX context. |
+ +---------------------+-----------------------------------------------------------------------+
| | editable | Yes/No; editable allows to edit directly from the list if authorized. |
+ +---------------------+-----------------------------------------------------------------------+
| | inverse | Yes/No; reverses the background color (green for false, red for true) |
+-----------+---------------------+-----------------------------------------------------------------------+
| choice | choices | Possible choices |
+ +---------------------+-----------------------------------------------------------------------+
| | multiple | Is it a multiple choice option? Defaults to false. |
+ +---------------------+-----------------------------------------------------------------------+
| | delimiter | Separator of values if multiple. |
+ +---------------------+-----------------------------------------------------------------------+
| | catalogue | Translation catalogue. |
+ +---------------------+-----------------------------------------------------------------------+
| | class | Class path for editable association field. |
+-----------+---------------------+-----------------------------------------------------------------------+
| currency | currency (m) | A currency string (EUR or USD for instance). |
+-----------+---------------------+-----------------------------------------------------------------------+
| date | 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 |
+-----------+---------------------+-----------------------------------------------------------------------+
| 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. |
+-----------+---------------------+-----------------------------------------------------------------------+
| percent | | Renders value as a percentage. |
+-----------+---------------------+-----------------------------------------------------------------------+
| string | | Renders a string. |
+-----------+---------------------+-----------------------------------------------------------------------+
| text | | See 'string' |
+-----------+---------------------+-----------------------------------------------------------------------+
| html | | Renders string as html |
+-----------+---------------------+-----------------------------------------------------------------------+
| time | | Renders a datetime's time with format ``H:i:s``. |
+-----------+---------------------+-----------------------------------------------------------------------+
| trans | catalogue | Translates the value with catalogue ``catalogue`` if defined. |
+-----------+---------------------+-----------------------------------------------------------------------+
| url | url | Adds a link with url ``url`` to the displayed value |
+ +---------------------+-----------------------------------------------------------------------+
| | route | Give a route to generate the url |
+ + + +
| | name | Route name |
+ + + +
| | parameters | Route parameters |
+ +---------------------+-----------------------------------------------------------------------+
| | hide_protocol | Hide http:// or https:// (default: false) |
+-----------+---------------------+-----------------------------------------------------------------------+
+----------------------------------+---------------------+-----------------------------------------------------------------------+
| Type | Options | Description |
+==================================+=====================+=======================================================================+
| ListMapper::TYPE_ACTIONS | actions | List of available actions |
+ + + +
| | edit | Name of the action (``show``, ``edit``, ``history``, ``delete``, etc) |
+ + + +
| | link_parameters | Route parameters |
+----------------------------------+---------------------+-----------------------------------------------------------------------+
| ListMapper::TYPE_BATCH | | Renders a checkbox |
+----------------------------------+---------------------+-----------------------------------------------------------------------+
| ListMapper::TYPE_SELECT | | Renders a select box |
+----------------------------------+---------------------+-----------------------------------------------------------------------+
| TemplateRegistry::TYPE_ARRAY | | Displays an array |
+----------------------------------+---------------------+-----------------------------------------------------------------------+
| TemplateRegistry::TYPE_BOOLEAN | ajax_hidden | Yes/No; ajax_hidden allows to hide list field during an AJAX context. |
+ +---------------------+-----------------------------------------------------------------------+
| | editable | Yes/No; editable allows to edit directly from the list if authorized. |
+ +---------------------+-----------------------------------------------------------------------+
| | inverse | Yes/No; reverses the background color (green for false, red for true) |
+----------------------------------+---------------------+-----------------------------------------------------------------------+
| TemplateRegistry::TYPE_CHOICE | choices | Possible choices |
+ +---------------------+-----------------------------------------------------------------------+
| | multiple | Is it a multiple choice option? Defaults to false. |
+ +---------------------+-----------------------------------------------------------------------+
| | delimiter | Separator of values if multiple. |
+ +---------------------+-----------------------------------------------------------------------+
| | catalogue | Translation catalogue. |
+ +---------------------+-----------------------------------------------------------------------+
| | class | Class path for editable association field. |
+ +---------------------+-----------------------------------------------------------------------+
| | editable | Yes/No; editable allows to edit directly from the list if authorized. |
+----------------------------------+---------------------+-----------------------------------------------------------------------+
| TemplateRegistry::TYPE_CURRENCY | currency (m) | A currency string (EUR or USD for instance). |
+ +---------------------+-----------------------------------------------------------------------+
| | editable | Yes/No; editable allows to edit directly from the list if authorized. |
+----------------------------------+---------------------+-----------------------------------------------------------------------+
| TemplateRegistry::TYPE_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. |
+----------------------------------+---------------------+-----------------------------------------------------------------------+
| TemplateRegistry::TYPE_TIME | format | A format understandable by Twig's ``date`` function. |
+ +---------------------+-----------------------------------------------------------------------+
| | timezone | Second argument for Twig's ``date`` function |
+----------------------------------+---------------------+-----------------------------------------------------------------------+
| TemplateRegistry::TYPE_DATETIME | format | A format understandable by Twig's ``date`` function. |
+ +---------------------+-----------------------------------------------------------------------+
| | timezone | Second argument for Twig's ``date`` function |
+----------------------------------+---------------------+-----------------------------------------------------------------------+
| TemplateRegistry::TYPE_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. |
+----------------------------------+---------------------+-----------------------------------------------------------------------+
| TemplateRegistry::TYPE_PERCENT | | Renders value as a percentage. |
+ +---------------------+-----------------------------------------------------------------------+
| | editable | Yes/No; editable allows to edit directly from the list if authorized. |
+----------------------------------+---------------------+-----------------------------------------------------------------------+
| TemplateRegistry::TYPE_STRING | | Renders a string. |
+ +---------------------+-----------------------------------------------------------------------+
| | editable | Yes/No; editable allows to edit directly from the list if authorized. |
+----------------------------------+---------------------+-----------------------------------------------------------------------+
| TemplateRegistry::TYPE_TEXTAREA | | See 'string' |
+----------------------------------+---------------------+-----------------------------------------------------------------------+
| TemplateRegistry::TYPE_HTML | | Renders string as html |
+ +---------------------+-----------------------------------------------------------------------+
| | editable | Yes/No; editable allows to edit directly from the list if authorized. |
+----------------------------------+---------------------+-----------------------------------------------------------------------+
| TemplateRegistry::TYPE_TRANS | catalogue | Translates the value with catalogue ``catalogue`` if defined. |
+----------------------------------+---------------------+-----------------------------------------------------------------------+
| TemplateRegistry::TYPE_URL | url | Adds a link with url ``url`` to the displayed value |
+ +---------------------+-----------------------------------------------------------------------+
| | route | Give a route to generate the url |
+ + + +
| | name | Route name |
+ + + +
| | parameters | Route parameters |
+ +---------------------+-----------------------------------------------------------------------+
| | hide_protocol | Hide http:// or https:// (default: false) |
+ +---------------------+-----------------------------------------------------------------------+
| | editable | Yes/No; editable allows to edit directly from the list if authorized. |
+----------------------------------+---------------------+-----------------------------------------------------------------------+
| TemplateRegistry::TYPE_INTEGER | | Renders a integer. |
+ +---------------------+-----------------------------------------------------------------------+
| | editable | Yes/No; editable allows to edit directly from the list if authorized. |
+----------------------------------+---------------------+-----------------------------------------------------------------------+

If you have the SonataDoctrineORMAdminBundle installed, you have access
to more field types, see `SonataDoctrineORMAdminBundle Documentation`_.
Expand Down
4 changes: 2 additions & 2 deletions src/Action/SetObjectFieldValueAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ public function __invoke(Request $request): JsonResponse
$propertyPath = new PropertyPath($field);
}

// Handle date and datetime types have setter expecting a DateTime object
if ('' !== $value && \in_array($fieldDescription->getType(), ['date', 'datetime'], true)) {
// Handle date type has setter expect a DateTime object
if ('' !== $value && 'date' === $fieldDescription->getType()) {
$value = new \DateTime($value);
}

Expand Down
Loading

0 comments on commit 8261ac2

Please sign in to comment.