SilverStripe\MultiForm\Models\MultiFormStep
MultiFormStep controls the behaviour of a single form step in the MultiForm process. All form steps are required to be subclasses of this class, as it encapsulates the functionality required for the step to be aware of itself in the process by knowing what it's next step is, and if applicable, it's previous step.
Synopsis
class MultiFormStep
extends DataObject
{
- // members
- private static array $db = ;
- private static array $has_one = ;
- private static string $table_name = 'MultiFormStep';
- private static array|string $next_steps;
- private static boolean $is_final_step = false;
- private static boolean $can_go_back = true;
- protected $title;
- protected MultiForm $form;
- protected array $extraClasses = ;
- protected array $step_data_cache = ;
- // methods
- public FieldList getFields()
- public FieldList getExtraActions()
- public bool|Validator getValidator()
- public string getTitle()
- public string Link()
- public array loadData()
- public void saveData()
- public DataObject saveInto()
- public boolean validateStep()
- public string getNextStep()
- public MultiFormStep|boolean|void getNextStepFromDatabase()
- public string|array getNextSteps()
- public string|void getPreviousStep()
- public MultiFormStep getPreviousStepFromDatabase()
- public string getPrevText()
- public string getNextText()
- public string getSubmitText()
- public void setForm()
- public Form getForm()
- public boolean canGoBack()
- public boolean isFinalStep()
- public boolean isCurrentStep()
- public MultiFormStep addExtraClass()
- public MultiFormStep removeExtraClass()
- public string getExtraClasses()
- public mixed getValueFromOtherStep()
- public void copyValueFromOtherStep()
- public MultiFormSession getSession()
Hierarchy
Extends
- SilverStripe\ORM\DataObject
Tasks
Line | Task |
---|---|
+ | This does not check if the arbitrarily chosen step using the step indicator is actually a previous step, so unless you remove the link from the indicator template, or type in StepID=23 to the address bar you can still go back using the step indicator. |
Members
private
- $can_go_back
—
boolean
This variable determines whether a user can use the "back" action from this step. - $db
- $has_one
- $is_final_step
—
boolean
Each {@link MultiForm} subclass needs at least one step which is marked as the "final" one and triggers the {@link MultiForm->finish()} method that wraps up the whole submission. - $next_steps
—
SilverStripe\MultiForm\Models\array|string
Centerpiece of the flow control for the form. - $table_name
protected
- $extraClasses
—
array
List of additional CSS classes for this step - $form
—
SilverStripe\MultiForm\Models\MultiForm
Form class that this step is directly related to. - $step_data_cache
—
array
Temporary cache to increase the performance for repeated look ups. - $title
—
string
Title of this step.
Methods
public
- Link() — Gets a direct link to this step (only works if you're allowed to skip steps, or this step has already been saved to the database for the current {@link MultiFormSession}).
- addExtraClass() — Add a CSS-class to the step. If needed, multiple classes can be added by delimiting a string with spaces.
- canGoBack() — Determines whether the user is able to go back using the "action_back" Determines whether the user is able to go back using the "action_back" Determines whether the user is able to go back using the "action_back" form action, based on the boolean value of $can_go_back.
- copyValueFromOtherStep() — allows to get a value from another step copied over
- getExtraActions() — Additional form actions to be added to this step.
- getExtraClasses()
- getFields() — Form fields to be rendered with this step.
- getForm()
- getNextStep() — Returns the first value of $next_step
- getNextStepFromDatabase() — Returns the next step to the current step in the database.
- getNextSteps() — Accessor method for self::$next_steps
- getNextText() — Get the text to use on the button to the next step.
- getPrevText() — Get the text to the use on the button to the previous step.
- getPreviousStep() — Returns the previous step, if there is one.
- getPreviousStepFromDatabase() — Retrieves the previous step class record from the database.
- getSession() — Gets the linked MultiFormSession
- getSubmitText() — Get the text to use on the button to submit the form.
- getTitle() — Accessor method for $this->title
- getValidator() — Get a validator specific to this form.
- getValueFromOtherStep() — Returns the submitted value, if any, of any steps.
- isCurrentStep() — Determines whether the currently viewed step is the current step set in the session.
- isFinalStep() — Determines whether this step is the final step in the multi-step process or not, based on the variable $is_final_step - which must be defined on at least one step.
- loadData() — Unserialize stored session data and return it.
- removeExtraClass() — Remove a CSS-class from the step. Multiple classes names can be passed through as a space delimited string.
- saveData() — Save the data for this step into session, serializing it first.
- saveInto() — Save the data on this step into an object, similiar to {@link Form->saveInto()} - by building a stub form from {@link getFields()}. This is necessary to trigger each {@link FormField->saveInto()} method individually, rather than assuming that all data serialized through {@link saveData()} can be saved as a simple value outside of the original FormField context.
- setForm() — Sets the form that this step is directly related to.
- validateStep() — Custom validation for a step. In most cases, it should be sufficient to have built-in validation through the {@link Validator} class on the {@link getValidator()} method.