Action ====== Base class: :doc:`Fragment` The `Action` class describes buttons and links. Examples: .. code-block:: python # Link example=Action(attrs__href='http://example.com'), # Link with icon edit=Action.icon('pencil-square', attrs__href="edit/"), # Button button=Action.button(display_name='Button title!'), # A submit button submit=Action.submit(display_name='Do this'), # The primary submit button on a form. primary=Action.primary(), .. raw:: html
▼ Hide result
Toggle structure
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 Form's 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: `int | str` See :ref:`after ` `assets` ^^^^^^^^ Type: `Namespace` See :ref:`assets ` `attrs`     (:ref:`evaluated `) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Type: :doc:`Attrs` See :ref:`attributes ` `children` ^^^^^^^^^^ Cookbook: :ref:`fragment-children` `display_name`     (:ref:`evaluated `) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Type: `str` Default: `lambda action, **_: capitalize(action._name).replace('_', ' ')` See :ref:`name ` `endpoints` ^^^^^^^^^^^ Type: `Namespace` See :ref:`endpoints ` `extra` ^^^^^^^ Type: `dict[str, Any]` See :ref:`extra ` `extra_evaluated` ^^^^^^^^^^^^^^^^^ Type: `dict[str, Any]` See :ref:`extra ` `extra_params` ^^^^^^^^^^^^^^ See :ref:`extra_params ` `group`     (:ref:`evaluated `) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Type: `str` Cookbook: :ref:`action-group` `include`     (:ref:`evaluated `) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Type: `bool` See :ref:`include ` `iommi_style` ^^^^^^^^^^^^^ Type: `str | Style | None` See :ref:`iommi_style ` `post_handler` ^^^^^^^^^^^^^^ Type: `Callable | None` Cookbook: :ref:`nested-forms` `tag`     (:ref:`evaluated `) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Default: `a` See :ref:`tag ` `template`     (:ref:`evaluated `) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Type: `str | Template` See :ref:`template