Action¶
Base class: Fragment
The Action class describes buttons and links.
Examples:
# 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(),
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:
class MyForm(Form):
class Meta:
@staticmethod
def actions__submit__post_handler(form, **_):
if not form.is_valid():
return
...
and is roughly equivalent to
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 (evaluated)¶
Type: Union[int, str]
See after
assets¶
Type: Namespace
See assets
attrs (evaluated)¶
Type: Attrs
See attributes
children¶
display_name (evaluated)¶
Type: str
- Default:
lambda action, **_: capitalize(action._name).replace('_', ' ') See name
endpoints¶
Type: Namespace
See endpoints
extra¶
Type: Dict[str, Any]
See extra
extra_evaluated¶
Type: Dict[str, Any]
See extra
extra_params¶
See extra_params
group (evaluated)¶
Type: str
include (evaluated)¶
Type: bool
See include
iommi_style¶
Type: str
See iommi_style
post_handler¶
Type: Callable
- Cookbook:
tag (evaluated)¶
- Default:
a See tag
template (evaluated)¶
Type: Union[str, Template]
See template
Shortcuts¶
Action.delete¶
Parent: Action.submit
Action.icon¶
Defaults¶
extra__icon_attrs__classNamespace()
extra__icon_attrs__styleNamespace()
Action.primary¶
Parent: Action.submit
Action.submit¶
Parent: Action.button
Defaults¶
attrs__accesskeys
attrs__namelambda action, **_: action.own_target_marker()
display_nameSubmit