mirror of
https://github.com/silverstripe/silverstripe-multiform
synced 2024-10-22 11:05:49 +02:00
API CHANGE Ticket #2562 - Cleaner instanciation of MultiForm subclass, init() is removed with the move of session/step initialization to __construct()
This commit is contained in:
parent
35f2de5de3
commit
295cd5077e
@ -74,15 +74,21 @@ abstract class MultiForm extends Form {
|
||||
);
|
||||
|
||||
/**
|
||||
* Perform actions when the multiform is first started.
|
||||
* We start the MultiForm here. Before we start the MultiForm process,
|
||||
* like setting up the session, we must pass in empty FieldSet objects
|
||||
* to the Form->__construct(), as it requires them to be present.
|
||||
*
|
||||
* It does NOT work like a normal controller init()! It has to be explicity called when MultiForm
|
||||
* is intanciated on your controller. @TODO perhaps find a better name, that doesn't quite conflict.
|
||||
*
|
||||
* This method sets up the session, figures out the current step, sets the current step, then
|
||||
* takes the fields, actions and validation (if any) for the step, setting up the form.
|
||||
* @param ContentController instance $controller Controller this form is created on
|
||||
* @param string $name The form name, typically the same as the method name
|
||||
*/
|
||||
public function init() {
|
||||
public function __construct($controller, $name) {
|
||||
|
||||
// We don't have any fields directly on here, they're on the step classes
|
||||
$fields = new FieldSet();
|
||||
$actions = new FieldSet();
|
||||
|
||||
parent::__construct($controller, $name, $fields, $actions);
|
||||
|
||||
// Set up the session for this MultiForm instance
|
||||
$this->setSession();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user