mirror of
https://github.com/silverstripe/silverstripe-userforms.git
synced 2024-10-22 15:05:42 +00:00
Replaced all instances of new FieldSet() with new FieldList()
Replaced the complex table field used for editing the email recipients with GridField Replaced instances of SAPPHIRE_DIR with FRAMEWORK_DIR Replaced instances of sapphire/ in css and templates with framework/ Re-organized tabs on user defined form so they are top level Replaced calls to toDropdownMap() with map() Renamed getCMSFields_forPopup() top getCMSFields()
This commit is contained in:
parent
584219b0b5
commit
5de26cd897
@ -95,7 +95,7 @@ class FieldEditor extends FormField {
|
||||
if($fields) {
|
||||
array_shift($fields); // get rid of subclass 0
|
||||
asort($fields); // get in order
|
||||
$output = new DataObjectSet();
|
||||
$output = new ArrayList();
|
||||
foreach($fields as $field => $title) {
|
||||
// get the nice title and strip out field
|
||||
$niceTitle = trim(eval("return $title::\$singular_name;"));
|
||||
|
@ -8,7 +8,7 @@
|
||||
class SubmittedFormReportField extends FormField {
|
||||
|
||||
function Field() {
|
||||
Requirements::css(SAPPHIRE_DIR . "/css/SubmittedFormReportField.css");
|
||||
Requirements::css(FRAMEWORK_DIR . "/css/SubmittedFormReportField.css");
|
||||
Requirements::javascript("userforms/javascript/UserForm.js");
|
||||
return $this->renderWith("SubmittedFormReportField");
|
||||
}
|
||||
@ -22,12 +22,12 @@ class SubmittedFormReportField extends FormField {
|
||||
$pageStart = isset($_REQUEST['start']) && is_numeric($_REQUEST['start']) ? $_REQUEST['start'] : 0;
|
||||
$pageLength = 10;
|
||||
|
||||
$items = $this->form->getRecord()->getComponents('Submissions', null, "\"Created\" DESC", null, "$pageStart,$pageLength");
|
||||
$items = $this->form->getRecord()->getComponents('Submissions', null, "\"Created\" DESC")->limit($pageStart,$pageLength);
|
||||
$formId = $this->form->getRecord()->ID;
|
||||
|
||||
foreach(DB::query("SELECT COUNT(*) AS \"CountRows\" FROM \"SubmittedForm\" WHERE \"ParentID\" = $formId") as $r) $totalCount = $r['CountRows'];
|
||||
|
||||
$items->setPageLimits($pageStart, $pageLength, $totalCount);
|
||||
//$items->setPageLimits($pageStart, $pageLength, $totalCount);
|
||||
$items->NextStart = $pageStart + $pageLength;
|
||||
$items->PrevStart = $pageStart - $pageLength;
|
||||
$items->Start = $pageStart;
|
||||
|
@ -57,43 +57,38 @@ class UserDefinedForm extends Page {
|
||||
$fields = parent::getCMSFields();
|
||||
|
||||
// define tabs
|
||||
$fields->findOrMakeTab('Root.Content.Form', _t('UserDefinedForm.FORM', 'Form'));
|
||||
$fields->findOrMakeTab('Root.Content.Options', _t('UserDefinedForm.OPTIONS', 'Options'));
|
||||
$fields->findOrMakeTab('Root.Content.EmailRecipients', _t('UserDefinedForm.EMAILRECIPIENTS', 'Email Recipients'));
|
||||
$fields->findOrMakeTab('Root.Content.OnComplete', _t('UserDefinedForm.ONCOMPLETE', 'On Complete'));
|
||||
$fields->findOrMakeTab('Root.Content.Submissions', _t('UserDefinedForm.SUBMISSIONS', 'Submissions'));
|
||||
$fields->findOrMakeTab('Root.Form', _t('UserDefinedForm.FORM', 'Form'));
|
||||
$fields->findOrMakeTab('Root.Options', _t('UserDefinedForm.OPTIONS', 'Options'));
|
||||
$fields->findOrMakeTab('Root.EmailRecipients', _t('UserDefinedForm.EMAILRECIPIENTS', 'Email Recipients'));
|
||||
$fields->findOrMakeTab('Root.OnComplete', _t('UserDefinedForm.ONCOMPLETE', 'On Complete'));
|
||||
$fields->findOrMakeTab('Root.Submissions', _t('UserDefinedForm.SUBMISSIONS', 'Submissions'));
|
||||
|
||||
// field editor
|
||||
$fields->addFieldToTab("Root.Content.Form", new FieldEditor("Fields", 'Fields', "", $this ));
|
||||
$fields->addFieldToTab("Root.Form", new FieldEditor("Fields", 'Fields', "", $this ));
|
||||
|
||||
// view the submissions
|
||||
$fields->addFieldToTab("Root.Content.Submissions", new CheckboxField('DisableSaveSubmissions',_t('UserDefinedForm.SAVESUBMISSIONS',"Disable Saving Submissions to Server")));
|
||||
$fields->addFieldToTab("Root.Content.Submissions", new SubmittedFormReportField( "Reports", _t('UserDefinedForm.RECEIVED', 'Received Submissions'), "", $this ) );
|
||||
$fields->addFieldToTab("Root.Submissions", new CheckboxField('DisableSaveSubmissions',_t('UserDefinedForm.SAVESUBMISSIONS',"Disable Saving Submissions to Server")));
|
||||
$fields->addFieldToTab("Root.Submissions", new SubmittedFormReportField( "Reports", _t('UserDefinedForm.RECEIVED', 'Received Submissions'), "", $this ) );
|
||||
|
||||
// who do we email on submission
|
||||
$emailRecipients = new ComplexTableField(
|
||||
$this,
|
||||
'EmailRecipients',
|
||||
'UserDefinedForm_EmailRecipient',
|
||||
array(
|
||||
UserDefinedForm_EmailRecipient::$summary_fields=array(
|
||||
'EmailAddress' => _t('UserDefinedForm.EMAILADDRESS', 'Email'),
|
||||
'EmailSubject' => _t('UserDefinedForm.EMAILSUBJECT', 'Subject'),
|
||||
'EmailFrom' => _t('UserDefinedForm.EMAILFROM', 'From')
|
||||
),
|
||||
'getCMSFields_forPopup',
|
||||
"\"FormID\" = '$this->ID'"
|
||||
);
|
||||
$emailRecipients->setAddTitle(_t('UserDefinedForm.AEMAILRECIPIENT', 'A Email Recipient'));
|
||||
|
||||
$fields->addFieldToTab("Root.Content.EmailRecipients", $emailRecipients);
|
||||
// who do we email on submission
|
||||
$emailRecipients = new GridField("EmailRecipients", "EmailRecipients", $this->EmailRecipients(), GridFieldConfig_RecordEditor::create(10));
|
||||
|
||||
$fields->addFieldToTab("Root.EmailRecipients", $emailRecipients);
|
||||
|
||||
// text to show on complete
|
||||
$onCompleteFieldSet = new FieldSet(
|
||||
new HtmlEditorField( "OnCompleteMessage", _t('UserDefinedForm.ONCOMPLETELABEL', 'Show on completion'),3,"",_t('UserDefinedForm.ONCOMPLETEMESSAGE', $this->OnCompleteMessage), $this )
|
||||
$onCompleteFieldSet = new FieldList(
|
||||
$editor=new HtmlEditorField( "OnCompleteMessage", _t('UserDefinedForm.ONCOMPLETELABEL', 'Show on completion'), _t('UserDefinedForm.ONCOMPLETEMESSAGE', $this->OnCompleteMessage))
|
||||
);
|
||||
$editor->setRows(3);
|
||||
|
||||
$fields->addFieldsToTab("Root.Content.OnComplete", $onCompleteFieldSet);
|
||||
$fields->addFieldsToTab("Root.Content.Options", $this->getFormOptions());
|
||||
$fields->addFieldsToTab("Root.OnComplete", $onCompleteFieldSet);
|
||||
$fields->addFieldsToTab("Root.Options", $this->getFormOptions());
|
||||
|
||||
return $fields;
|
||||
}
|
||||
@ -259,7 +254,7 @@ class UserDefinedForm extends Page {
|
||||
public function getFormOptions() {
|
||||
$submit = ($this->SubmitButtonText) ? $this->SubmitButtonText : _t('UserDefinedForm.SUBMITBUTTON', 'Submit');
|
||||
|
||||
$options = new FieldSet(
|
||||
$options = new FieldList(
|
||||
new TextField("SubmitButtonText", _t('UserDefinedForm.TEXTONSUBMIT', 'Text on submit button:'), $submit),
|
||||
new CheckboxField("ShowClearButton", _t('UserDefinedForm.SHOWCLEARFORM', 'Show Clear Form Button'), $this->ShowClearButton)
|
||||
);
|
||||
@ -302,7 +297,7 @@ class UserDefinedForm_Controller extends Page_Controller {
|
||||
Validator::set_javascript_validation_handler('none');
|
||||
|
||||
// load the jquery
|
||||
Requirements::javascript(SAPPHIRE_DIR .'/thirdparty/jquery/jquery.js');
|
||||
Requirements::javascript(FRAMEWORK_DIR .'/thirdparty/jquery/jquery.js');
|
||||
Requirements::javascript('userforms/thirdparty/jquery-validate/jquery.validate.min.js');
|
||||
}
|
||||
|
||||
@ -368,7 +363,7 @@ class UserDefinedForm_Controller extends Page_Controller {
|
||||
* @return FieldSet
|
||||
*/
|
||||
function getFormFields() {
|
||||
$fields = new FieldSet();
|
||||
$fields = new FieldList();
|
||||
|
||||
if($this->Fields()) {
|
||||
foreach($this->Fields() as $editableField) {
|
||||
@ -428,7 +423,7 @@ class UserDefinedForm_Controller extends Page_Controller {
|
||||
function getFormActions() {
|
||||
$submitText = ($this->SubmitButtonText) ? $this->SubmitButtonText : _t('UserDefinedForm.SUBMITBUTTON', 'Submit');
|
||||
|
||||
$actions = new FieldSet(
|
||||
$actions = new FieldList(
|
||||
new FormAction("process", $submitText)
|
||||
);
|
||||
|
||||
@ -843,9 +838,9 @@ class UserDefinedForm_EmailRecipient extends DataObject {
|
||||
* Return the fields to edit this email.
|
||||
* @return FieldSet
|
||||
*/
|
||||
public function getCMSFields_forPopup() {
|
||||
public function getCMSFields() {
|
||||
|
||||
$fields = new FieldSet(
|
||||
$fields = new FieldList(
|
||||
new TextField('EmailSubject', _t('UserDefinedForm.EMAILSUBJECT', 'Email Subject')),
|
||||
new TextField('EmailFrom', _t('UserDefinedForm.FROMADDRESS','Send Email From')),
|
||||
new TextField('EmailAddress', _t('UserDefinedForm.SENDEMAILTO','Send Email To')),
|
||||
@ -860,21 +855,22 @@ class UserDefinedForm_EmailRecipient extends DataObject {
|
||||
|
||||
// if they have email fields then we could send from it
|
||||
if($validEmailFields) {
|
||||
$fields->insertAfter(new DropdownField('SendEmailFromFieldID', _t('UserDefinedForm.ORSELECTAFIELDTOUSEASFROM', '.. or Select a Form Field to use as the From Address'), $validEmailFields->toDropdownMap('ID', 'Title'), '', null,""), 'EmailFrom');
|
||||
$fields->insertAfter(new DropdownField('SendEmailFromFieldID', _t('UserDefinedForm.ORSELECTAFIELDTOUSEASFROM', '.. or Select a Form Field to use as the From Address'), $validEmailFields->map('ID', 'Title'), '', null,""), 'EmailFrom');
|
||||
}
|
||||
|
||||
// if they have multiple options
|
||||
if($multiOptionFields || $validEmailFields) {
|
||||
|
||||
if($multiOptionFields && $validEmailFields) {
|
||||
$multiOptionFields->merge($validEmailFields);
|
||||
|
||||
$multiOptionFields=$multiOptionFields->toArray();
|
||||
$multiOptionFields=array_merge($multiOptionFields, $validEmailFields->toArray());
|
||||
$multiOptionFields=ArrayList::create($multiOptionFields);
|
||||
}
|
||||
elseif(!$multiOptionFields) {
|
||||
$multiOptionFields = $validEmailFields;
|
||||
}
|
||||
|
||||
$multiOptionFields = $multiOptionFields->toDropdownMap('ID', 'Title');
|
||||
$multiOptionFields = $multiOptionFields->map('ID', 'Title');
|
||||
$fields->insertAfter(new DropdownField('SendEmailToFieldID', _t('UserDefinedForm.ORSELECTAFIELDTOUSEASTO', '.. or Select a Field to use as the To Address'), $multiOptionFields, '', null, ""), 'EmailAddress');
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ class EditableDateField extends EditableFormField {
|
||||
$default = ($this->getSetting('DefaultToToday')) ? $this->getSetting('DefaultToToday') : false;
|
||||
$label = _t('EditableFormField.DEFAULTTOTODAY', 'Default to Today?');
|
||||
|
||||
return new FieldSet(
|
||||
return new FieldList(
|
||||
new CheckboxField($this->getSettingName("DefaultToToday"), $label, $default)
|
||||
);
|
||||
}
|
||||
|
@ -391,7 +391,7 @@ class EditableFormField extends DataObject {
|
||||
$this->getSetting('RightTitle')
|
||||
);
|
||||
|
||||
return new FieldSet(
|
||||
return new FieldList(
|
||||
$ec,
|
||||
$right
|
||||
);
|
||||
@ -404,7 +404,7 @@ class EditableFormField extends DataObject {
|
||||
* @return FieldSet
|
||||
*/
|
||||
public function getFieldValidationOptions() {
|
||||
$fields = new FieldSet(
|
||||
$fields = new FieldList(
|
||||
new CheckboxField($this->getFieldName('Required'), _t('EditableFormField.REQUIRED', 'Is this field Required?'), $this->Required),
|
||||
new TextField($this->getFieldName('CustomErrorMessage'), _t('EditableFormField.CUSTOMERROR','Custom Error Message'), $this->CustomErrorMessage)
|
||||
);
|
||||
|
@ -14,7 +14,7 @@ class EditableLiteralField extends EditableFormField {
|
||||
static $plural_name = 'HTML Blocks';
|
||||
|
||||
function getFieldConfiguration() {
|
||||
return new FieldSet(
|
||||
return new FieldList(
|
||||
new TextareaField(
|
||||
$this->getSettingName('Content'),
|
||||
"HTML", 4, 20, $this->getSetting('Content')
|
||||
|
@ -17,7 +17,7 @@ class EditableMemberListField extends EditableFormField {
|
||||
|
||||
if($groups) $groups = $groups->toDropdownMap('ID', 'Title');
|
||||
|
||||
$fields = new FieldSet(
|
||||
$fields = new FieldList(
|
||||
new DropdownField("Fields[$this->ID][CustomSettings][GroupID]", _t('EditableFormField.GROUP', 'Group'), $groups, $groupID)
|
||||
);
|
||||
|
||||
|
@ -21,7 +21,7 @@ class EditableTextField extends EditableFormField {
|
||||
|
||||
$rows = ($this->getSetting('Rows')) ? $this->getSetting('Rows') : '1';
|
||||
|
||||
$extraFields = new FieldSet(
|
||||
$extraFields = new FieldList(
|
||||
new FieldGroup(_t('EditableTextField.TEXTLENGTH', 'Text length'),
|
||||
new TextField($this->getSettingName('MinLength'), "", $min),
|
||||
new TextField($this->getSettingName('MaxLength'), " - ", $max)
|
||||
|
@ -2,9 +2,9 @@
|
||||
<li class="$ClassName EditableFormField" id="$Name.ATT EditableItem_$Pos $Name">
|
||||
<div class="fieldInfo">
|
||||
<% if canEdit %>
|
||||
<img class="fieldHandler" src="sapphire/images/drag.gif" alt="<% _t('DRAG', 'Drag to rearrange order of fields') %>" />
|
||||
<img class="fieldHandler" src="framework/images/drag.gif" alt="<% _t('DRAG', 'Drag to rearrange order of fields') %>" />
|
||||
<% else %>
|
||||
<img class="fieldHandler" src="sapphire/images/drag_readonly.gif" alt="<% _t('LOCKED', 'These fields cannot be modified') %>" />
|
||||
<img class="fieldHandler" src="framework/images/drag_readonly.gif" alt="<% _t('LOCKED', 'These fields cannot be modified') %>" />
|
||||
<% end_if %>
|
||||
|
||||
<img class="icon" src="$Icon" alt="$ClassName" title="$singular_name" />
|
||||
|
@ -1,5 +1,5 @@
|
||||
<li>
|
||||
<img class="handle" src="sapphire/images/drag.gif" alt="<% _t('DRAG', 'Drag to rearrange order of options') %>" />
|
||||
<img class="handle" src="framework/images/drag.gif" alt="<% _t('DRAG', 'Drag to rearrange order of options') %>" />
|
||||
<input type="text" name="{$FieldName}[Title]" value="$Title" />
|
||||
<input type="hidden" class="sortOptionHidden hidden" name="{$FieldName}[Sort]" value="$Sort" />
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
<% require css(userforms/css/FieldEditor.css) %>
|
||||
<% require javascript(sapphire/thirdparty/jquery-ui/jquery-ui.custom.js) %>
|
||||
<% require javascript(sapphire/thirdparty/jquery-ui/jquery-ui-1.8rc3.custom.js) %>
|
||||
<% require javascript(framework/thirdparty/jquery-ui/jquery-ui.js) %>
|
||||
<% require javascript(userforms/javascript/UserForm.js) %>
|
||||
|
||||
<div class="FieldEditor <% if canEdit %><% else %>readonly<% end_if %>" id="Fields">
|
||||
|
@ -41,6 +41,6 @@ class FieldEditorTest extends FunctionalTest {
|
||||
class FieldEditorTest_Controller extends Controller {
|
||||
|
||||
function Form() {
|
||||
return new Form($this, 'Form', new FieldSet(new FieldEditor('Fields')), new FieldSet());
|
||||
return new Form($this, 'Form', new FieldList(new FieldEditor('Fields')), new FieldList());
|
||||
}
|
||||
}
|
@ -144,7 +144,7 @@ class SubmittedFormTest extends FunctionalTest {
|
||||
class SubmittedFormTest_Controller extends ContentController {
|
||||
|
||||
function Form() {
|
||||
$form = new Form($this, 'Form', new FieldSet(new SubmittedFormReportField('Report')), new FieldSet(new FormAction('Submit')));
|
||||
$form = new Form($this, 'Form', new FieldList(new SubmittedFormReportField('Report')), new FieldList(new FormAction('Submit')));
|
||||
|
||||
$form->loadDataFrom($this->data());
|
||||
|
||||
|
@ -129,7 +129,7 @@ class UserDefinedFormControllerTest extends FunctionalTest {
|
||||
$actions = $controller->getFormActions();
|
||||
|
||||
// by default will have 1 submit button which links to process
|
||||
$expected = new FieldSet(new FormAction('process', 'Submit'));
|
||||
$expected = new FieldList(new FormAction('process', 'Submit'));
|
||||
|
||||
$this->assertEquals($actions, $expected);
|
||||
|
||||
@ -139,7 +139,7 @@ class UserDefinedFormControllerTest extends FunctionalTest {
|
||||
|
||||
$actions = $controller->getFormActions();
|
||||
|
||||
$expected = new FieldSet(new FormAction('process', 'Custom Button'));
|
||||
$expected = new FieldList(new FormAction('process', 'Custom Button'));
|
||||
$expected->push(new ResetFormAction("clearForm"));
|
||||
|
||||
$this->assertEquals($actions, $expected);
|
||||
|
@ -56,7 +56,7 @@ class UserDefinedFormTest extends FunctionalTest {
|
||||
|
||||
$popup = new UserDefinedForm_EmailRecipient();
|
||||
|
||||
$fields = $popup->getCMSFields_forPopup();
|
||||
$fields = $popup->getCMSFields();
|
||||
|
||||
$this->assertTrue($fields->dataFieldByName('EmailSubject') !== null);
|
||||
$this->assertTrue($fields->dataFieldByName('EmailFrom') !== null);
|
||||
@ -72,14 +72,14 @@ class UserDefinedFormTest extends FunctionalTest {
|
||||
$popup->FormID = $form->ID;
|
||||
$popup->write();
|
||||
|
||||
$fields = $popup->getCMSFields_forPopup();
|
||||
$fields = $popup->getCMSFields();
|
||||
$this->assertThat($fields->fieldByName('SendEmailToFieldID'), $this->isInstanceOf('DropdownField'));
|
||||
|
||||
// if the front end has checkboxs or dropdown they can select from that can also be used to send things
|
||||
$dropdown = $this->objFromFixture('EditableDropdown', 'department-dropdown');
|
||||
$form->Fields()->add($dropdown);
|
||||
|
||||
$fields = $popup->getCMSFields_forPopup();
|
||||
$fields = $popup->getCMSFields();
|
||||
$this->assertTrue($fields->dataFieldByName('SendEmailToFieldID') !== null);
|
||||
|
||||
$popup->delete();
|
||||
|
Loading…
x
Reference in New Issue
Block a user