Actions

An Action may apply reversible modifications of a django Form.

It should always take a list of :py:cls:`~facond.conditions.Condition` as first argument, and then whatever it’s going to need to work.

Action

JavaScript

class Action(conditions)

Apply a reversible action on the DOM if conditions apply, unapply otherwise.

Arguments:
Action.apply(form)

Modify the DOM, should save the state for unapply().

Arguments:
  • formForm() object to apply on.
Action.execute(form)

Call apply() if conditions validate, unapply() otherwise.

Arguments:
  • formForm() object to execute on.
Action.unapply(form)

Restore the DOM prior to apply() call.

Arguments:
  • formForm() object to unapply on.

Python

class facond.actions.Action(conditions)[source]

An action to take on a list of fields.

The execute() will first execute validate() for every of its conditions against the :py:cls:`~facond.forms.Form` instance it is passed.

apply(form)[source]

Actual application of the action on the form field.

execute(form)[source]

Prevent the action from being applied if conditions don’t pass.

unapply(form)[source]

Revert apply() action.

RemoveChoices

JavaScript

class RemoveChoices(conditions, field, choices)

Remove given choices from a field.

Arguments:

Python

class facond.actions.RemoveChoices(conditions, field, choices)[source]

Remove choices from a choice field.

apply(form)[source]

Raise a ValidationError if the field value is in self.values.

RemoveField

JavaScript

class RemoveField(conditions, field)

Remove a field from a form.

Arguments:

:param Field(): Subject Field instance.

Python

class facond.actions.RemoveField(conditions, field)[source]

Remove fields from a form.

apply(form)[source]

Remove the field and data from field.form.

unapply(form)[source]

Restore the field and data in field.form.