mirror of
https://github.com/silverstripe/silverstripe-frameworktest
synced 2024-10-22 11:06:02 +02:00
ENHANCEMENT: use FieldList constructor to replace FieldSet constructor for SilverStripe 3
ENHANCEMENT: use FormActioin constructor to replace ImageFormAction constructor for SilverStripe 3
This commit is contained in:
parent
2ca8ff1c7d
commit
0a4f22a08f
@ -22,11 +22,11 @@ class FrameworktestRegressSessionAdmin extends Controller {
|
|||||||
$isRunning = (Session::get('db'));
|
$isRunning = (Session::get('db'));
|
||||||
|
|
||||||
if($isRunning) {
|
if($isRunning) {
|
||||||
$actions = new FieldSet(
|
$actions = new FieldList(
|
||||||
new FormAction('endsession', 'End Session')
|
new FormAction('endsession', 'End Session')
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
$actions = new FieldSet(
|
$actions = new FieldList(
|
||||||
new FormAction('startsession', 'Start Session')
|
new FormAction('startsession', 'Start Session')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -34,7 +34,7 @@ class FrameworktestRegressSessionAdmin extends Controller {
|
|||||||
$form = new Form(
|
$form = new Form(
|
||||||
$this,
|
$this,
|
||||||
'Form',
|
'Form',
|
||||||
new FieldSet(
|
new FieldList(
|
||||||
new HeaderField('Header1', ($isRunning) ? 'Session is already running' : 'Start new regress session'),
|
new HeaderField('Header1', ($isRunning) ? 'Session is already running' : 'Start new regress session'),
|
||||||
new LiteralField('Lit1',
|
new LiteralField('Lit1',
|
||||||
'<p>Use this form to set configuration prior to starting a <a href="http://regress.silverstripe.com">regress.silverstripe.com</a> test session (manual testing).</p>'
|
'<p>Use this form to set configuration prior to starting a <a href="http://regress.silverstripe.com">regress.silverstripe.com</a> test session (manual testing).</p>'
|
||||||
|
@ -7,13 +7,13 @@ class TestFileUploadPage extends TestPage{
|
|||||||
class TestFileUploadPage_Controller extends TestPage_Controller{
|
class TestFileUploadPage_Controller extends TestPage_Controller{
|
||||||
|
|
||||||
function Form(){
|
function Form(){
|
||||||
$fields = new FieldSet(
|
$fields = new FieldList(
|
||||||
new EmailField('Email', 'EmailField'),
|
new EmailField('Email', 'EmailField'),
|
||||||
new FileField('AFile','FileField'),
|
new FileField('AFile','FileField'),
|
||||||
new SimpleImageField('AImage','SimpleImageField')
|
new SimpleImageField('AImage','SimpleImageField')
|
||||||
);
|
);
|
||||||
|
|
||||||
$actions = new FieldSet(
|
$actions = new FieldList(
|
||||||
new FormAction('addMember', "Add a member with two Files uploaded")
|
new FormAction('addMember', "Add a member with two Files uploaded")
|
||||||
);
|
);
|
||||||
return new Form($this, "Form", $fields, $actions);
|
return new Form($this, "Form", $fields, $actions);
|
||||||
|
@ -40,10 +40,11 @@ class TestPage_Controller extends Page_Controller {
|
|||||||
*/
|
*/
|
||||||
function Form() {
|
function Form() {
|
||||||
$fields = $this->getCMSFields();
|
$fields = $this->getCMSFields();
|
||||||
$actions = new FieldSet(
|
$actions = new FieldList(
|
||||||
new FormAction("save", "Save"),
|
new FormAction("save", "Save"),
|
||||||
new ImageFormAction("gohome", "Go home", "frameworktest/images/test-button.png")
|
$gohome = new FormAction("gohome", "Go home")
|
||||||
);
|
);
|
||||||
|
$gohome->setAttribute('src', 'frameworktest/images/test-button.png');
|
||||||
$form = new Form($this, "Form", $fields, $actions);
|
$form = new Form($this, "Form", $fields, $actions);
|
||||||
$form->loadDataFrom($this->dataRecord);
|
$form->loadDataFrom($this->dataRecord);
|
||||||
return $form;
|
return $form;
|
||||||
@ -60,9 +61,9 @@ class TestPage_Controller extends Page_Controller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function EmailForm() {
|
function EmailForm() {
|
||||||
return new Form($this, "EmailForm", new FieldSet(
|
return new Form($this, "EmailForm", new FieldList(
|
||||||
new TextField("Email", "Email address")
|
new TextField("Email", "Email address")
|
||||||
), new FieldSet(
|
), new FieldList(
|
||||||
new FormAction("sendEmail", "Send test email to this address")
|
new FormAction("sendEmail", "Send test email to this address")
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,7 @@ class Page2PersonalDetailsFormStep extends MultiFormStep {
|
|||||||
public static $next_steps = 'Page2OrganisationDetailsFormStep';
|
public static $next_steps = 'Page2OrganisationDetailsFormStep';
|
||||||
|
|
||||||
function getFields() {
|
function getFields() {
|
||||||
return new FieldSet(
|
return new FieldList(
|
||||||
new TextField('FirstName', 'First name'),
|
new TextField('FirstName', 'First name'),
|
||||||
new TextField('Surname', 'Surname')
|
new TextField('Surname', 'Surname')
|
||||||
);
|
);
|
||||||
@ -54,7 +54,7 @@ class Page2OrganisationDetailsFormStep extends MultiFormStep {
|
|||||||
public static $is_final_step = true;
|
public static $is_final_step = true;
|
||||||
|
|
||||||
function getFields() {
|
function getFields() {
|
||||||
return new FieldSet(
|
return new FieldList(
|
||||||
new TextField('OrganisationName', 'Organisation Name')
|
new TextField('OrganisationName', 'Organisation Name')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ class Page3StartFormStep extends MultiFormStep {
|
|||||||
public static $next_steps = 'Page3PersonalDetailsFormStep';
|
public static $next_steps = 'Page3PersonalDetailsFormStep';
|
||||||
|
|
||||||
function getFields() {
|
function getFields() {
|
||||||
return new FieldSet(
|
return new FieldList(
|
||||||
new LiteralField('Details', '<b>This is important</b><br />
|
new LiteralField('Details', '<b>This is important</b><br />
|
||||||
<p>You will receiving email once you participate in this survey. <br />
|
<p>You will receiving email once you participate in this survey. <br />
|
||||||
Under the new Unsolicited Electronic Messages Act 2007, we must have your consent to send emails relating to this form. <br />
|
Under the new Unsolicited Electronic Messages Act 2007, we must have your consent to send emails relating to this form. <br />
|
||||||
@ -61,7 +61,7 @@ class Page3PersonalDetailsFormStep extends MultiFormStep {
|
|||||||
public static $next_steps = 'Page3OrganisationDetailsFormStep';
|
public static $next_steps = 'Page3OrganisationDetailsFormStep';
|
||||||
|
|
||||||
function getFields() {
|
function getFields() {
|
||||||
return new FieldSet(
|
return new FieldList(
|
||||||
new TextField('FirstName', 'First name'),
|
new TextField('FirstName', 'First name'),
|
||||||
new TextField('Surname', 'Surname')
|
new TextField('Surname', 'Surname')
|
||||||
);
|
);
|
||||||
@ -75,7 +75,7 @@ class Page3OrganisationDetailsFormStep extends MultiFormStep {
|
|||||||
public static $is_final_step = true;
|
public static $is_final_step = true;
|
||||||
|
|
||||||
function getFields() {
|
function getFields() {
|
||||||
return new FieldSet(
|
return new FieldList(
|
||||||
new TextField('OrganisationName', 'Organisation Name')
|
new TextField('OrganisationName', 'Organisation Name')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ class TestMultiForm extends MultiForm {
|
|||||||
$savedData = array_merge($savedData, $step->loadData());
|
$savedData = array_merge($savedData, $step->loadData());
|
||||||
}
|
}
|
||||||
|
|
||||||
$fields = new FieldSet();
|
$fields = new FieldList();
|
||||||
$fields->push(new LiteralField("Heading", "<h3>You have submitted the following information:</h3>"));
|
$fields->push(new LiteralField("Heading", "<h3>You have submitted the following information:</h3>"));
|
||||||
|
|
||||||
foreach($savedData as $key=>$value) {
|
foreach($savedData as $key=>$value) {
|
||||||
@ -29,7 +29,7 @@ class TestMultiFormStepOne extends MultiFormStep {
|
|||||||
public static $next_steps = 'TestMultiFormStepTwo';
|
public static $next_steps = 'TestMultiFormStepTwo';
|
||||||
|
|
||||||
function getFields() {
|
function getFields() {
|
||||||
return new FieldSet(
|
return new FieldList(
|
||||||
new TextField('FirstName', 'First name'),
|
new TextField('FirstName', 'First name'),
|
||||||
new TextField('Surname', 'Surname')
|
new TextField('Surname', 'Surname')
|
||||||
);
|
);
|
||||||
@ -42,7 +42,7 @@ class TestMultiFormStepTwo extends MultiFormStep {
|
|||||||
|
|
||||||
function getFields() {
|
function getFields() {
|
||||||
|
|
||||||
return new FieldSet(
|
return new FieldList(
|
||||||
new TextField('Email', 'Email'),
|
new TextField('Email', 'Email'),
|
||||||
new TextField('Address', 'Address')
|
new TextField('Address', 'Address')
|
||||||
);
|
);
|
||||||
@ -62,7 +62,7 @@ class TestMultiFormStepThree extends MultiFormStep {
|
|||||||
$savedData = array_merge($savedData, $step->loadData());
|
$savedData = array_merge($savedData, $step->loadData());
|
||||||
}
|
}
|
||||||
|
|
||||||
$fields = new FieldSet();
|
$fields = new FieldList();
|
||||||
$fields->push(new LiteralField("Heading", "<h3>You have submitted the following information:</h3>"));
|
$fields->push(new LiteralField("Heading", "<h3>You have submitted the following information:</h3>"));
|
||||||
|
|
||||||
foreach($savedData as $key=>$value) {
|
foreach($savedData as $key=>$value) {
|
||||||
|
@ -6,7 +6,7 @@ class TestMultiFormPage extends Page {
|
|||||||
class TestMultiFormPage_Controller extends Page_Controller {
|
class TestMultiFormPage_Controller extends Page_Controller {
|
||||||
|
|
||||||
function Form() {
|
function Form() {
|
||||||
$form = new TestMultiForm($this, 'Form', new FieldSet(), new FieldSet());
|
$form = new TestMultiForm($this, 'Form', new FieldList(), new FieldList());
|
||||||
|
|
||||||
return $form;
|
return $form;
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ class RecaptchaTestPage extends Page {
|
|||||||
class RecaptchaTestPage_Controller extends Page_Controller {
|
class RecaptchaTestPage_Controller extends Page_Controller {
|
||||||
|
|
||||||
function Form() {
|
function Form() {
|
||||||
$fields = new FieldSet(
|
$fields = new FieldList(
|
||||||
new TextField('MyText')
|
new TextField('MyText')
|
||||||
);
|
);
|
||||||
if(class_exists('RecaptchaField')) {
|
if(class_exists('RecaptchaField')) {
|
||||||
@ -19,7 +19,7 @@ class RecaptchaTestPage_Controller extends Page_Controller {
|
|||||||
$this,
|
$this,
|
||||||
'Form',
|
'Form',
|
||||||
$fields,
|
$fields,
|
||||||
new FieldSet(
|
new FieldList(
|
||||||
new FormAction('submit', 'submit')
|
new FormAction('submit', 'submit')
|
||||||
),
|
),
|
||||||
new RequiredFields(array('MyText'))
|
new RequiredFields(array('MyText'))
|
||||||
|
Loading…
Reference in New Issue
Block a user