DOC new instance creation updated to use Injectable::create()

This commit is contained in:
Franco Springveldt 2017-09-10 20:15:43 +12:00
parent a3e7422f25
commit 972786715c
1 changed files with 12 additions and 12 deletions

View File

@ -146,9 +146,9 @@ class SurveyFormPersonalDetailsStep extends MultiFormStep {
private static $next_steps = 'SurveyFormOrganisationDetailsStep'; private static $next_steps = 'SurveyFormOrganisationDetailsStep';
public function getFields() { public function getFields() {
return new FieldList( return FieldList::create(
new TextField('FirstName', 'First name'), TextField::create('FirstName', 'First name'),
new TextField('Surname', 'Surname') TextField::create('Surname', 'Surname')
); );
} }
@ -207,7 +207,7 @@ class Page_Controller extends ContentController {
); );
public function SurveyForm() { public function SurveyForm() {
return new SurveyForm($this, 'Form'); return SurveyForm::create($this, 'Form');
} }
public function finished() { public function finished() {
@ -339,8 +339,8 @@ class Step1 extends MultiFormStep
private static $next_steps = 'Step2'; private static $next_steps = 'Step2';
public function getFields() { public function getFields() {
return new FieldList( return FieldList::create(
new EmailField('Email', 'Your email') EmailField::create('Email', 'Your email')
); );
} }
} }
@ -350,9 +350,9 @@ class Step2 extends MultiFormStep
private static $next_steps = 'Step3'; private static $next_steps = 'Step3';
public function getFields() { public function getFields() {
$fields = new FieldList( $fields = FieldList::create(
new EmailField('Email', 'E-mail'), EmailField::create('Email', 'E-mail'),
new EmailField('Email2', 'Verify E-Mail') EmailField::create('Email2', 'Verify E-Mail')
); );
// set the email field to the input from Step 1 // set the email field to the input from Step 1
@ -393,7 +393,7 @@ class SurveyForm extends MultiForm {
if($steps) { if($steps) {
foreach($steps as $step) { foreach($steps as $step) {
if($step->class == 'SurveyFormPersonalDetailsStep') { if($step->class == 'SurveyFormPersonalDetailsStep') {
$member = new Member(); $member = Member::create();
$data = $step->loadData(); $data = $step->loadData();
if($data) { if($data) {
@ -403,7 +403,7 @@ class SurveyForm extends MultiForm {
} }
if($step->class == 'SurveyOrganisationDetailsStep') { if($step->class == 'SurveyOrganisationDetailsStep') {
$organisation = new Organisation(); $organisation = Organisation::create();
$data = $step->loadData(); $data = $step->loadData();
if($data) { if($data) {
@ -532,7 +532,7 @@ class MyStep extends MultiFormStep {
... ...
public function getValidator() { public function getValidator() {
return new RequiredFields(array( return RequiredFields::create(array(
'Name', 'Name',
'Email' 'Email'
)); ));