Action
======
Base class: :doc:`Fragment`
The `Action` class describes buttons and links.
Examples:
.. code-block:: python
# Link
Action(attrs__href='http://example.com'),
# Link with icon
Action.icon('edit', attrs__href="edit/"),
# Button
Action.button(display_name='Button title!'),
# A submit button
Action.submit(display_name='Do this'),
# The primary submit button on a form.
Action.primary(),
.. raw:: html
▼ Hide result
Notice that because forms
with a single primary submit button are so common, iommi assumes
that if you have an action called submit and do NOT explicitly
specify the action that it is a primary action. This is only
done for the action called submit, inside the Forms actions
Namespace.
For that reason this works:
.. code-block:: python
class MyForm(Form):
class Meta:
@staticmethod
def actions__submit__post_handler(form, **_):
if not form.is_valid():
return
...
and is roughly equivalent to
.. code-block:: python
def on_submit(form, **_):
if not form.is_valid():
return
class MyOtherForm(Form):
class Meta:
actions__submit = Action.primary(post_handler=on_submit)
Refinable members
-----------------
* `after` (:ref:`evaluated `)
Type: `Union[int, str]`
* `assets`
Type: `Namespace`
* `attrs` (:ref:`evaluated `)
Type: :doc:`Attrs`
* `children`
* `display_name` (:ref:`evaluated `)
Type: `str`
Default: `lambda action, **_: capitalize(action._name).replace('_', ' ')`
* `endpoints`
Type: `Namespace`
* `extra`
Type: `Dict[str, Any]`
* `extra_evaluated`
Type: `Dict[str, Any]`
* `extra_params`
* `group` (:ref:`evaluated `)
Type: `str`
* `include` (:ref:`evaluated `)
Type: `bool`
* `iommi_style`
Type: `str`
* `post_handler`
Type: `Callable`
* `tag` (:ref:`evaluated `)
Default: `a`
* `template` (:ref:`evaluated `)
Type: `Union[str, iommi._web_compat.Template]`
Shortcuts
---------
`Action.button`
^^^^^^^^^^^^^^^
Defaults
++++++++
* `tag`
* `button`
`Action.delete`
^^^^^^^^^^^^^^^
Parent: Action.submit_
`Action.icon`
^^^^^^^^^^^^^
`Action.primary`
^^^^^^^^^^^^^^^^
Parent: Action.submit_
`Action.submit`
^^^^^^^^^^^^^^^
Parent: Action.button_
Defaults
++++++++
* `attrs__accesskey`
* `s`
* `attrs__name`
* `lambda action, **_: action.own_target_marker()`
* `display_name`
* `Submit`
Methods
-------
`is_target`
^^^^^^^^^^^
`on_bind`
^^^^^^^^^
`on_refine_done`
^^^^^^^^^^^^^^^^
`own_evaluate_parameters`
^^^^^^^^^^^^^^^^^^^^^^^^^
`own_target_marker`
^^^^^^^^^^^^^^^^^^^