Merge branch '5.2'

This commit is contained in:
Robbie Averill 2018-09-22 13:54:33 +02:00
commit 3bc2b45170
7 changed files with 34 additions and 20 deletions

View File

@ -71,6 +71,11 @@ class UpgradePolymorphicExtension extends DataExtension
continue;
}
// Don't rewrite class values when an existing value is set and is an instance of UserDefinedForm
if ($relationshipObject instanceof UserDefinedForm) {
continue;
}
$entry->$fieldName = $this->defaultReplacement;
try {
$entry->write();

View File

@ -27,6 +27,7 @@ use SilverStripe\ORM\ArrayList;
use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\DB;
use SilverStripe\ORM\FieldType\DBField;
use SilverStripe\ORM\FieldType\DBVarchar;
use SilverStripe\ORM\ValidationException;
use SilverStripe\UserForms\Extension\UserFormFieldEditorExtension;
use SilverStripe\UserForms\Model\EditableFormField\EditableFieldGroup;
@ -801,12 +802,12 @@ class EditableFormField extends DataObject
* Return the error message for this field. Either uses the custom
* one (if provided) or the default SilverStripe message
*
* @return Varchar
* @return DBVarchar
*/
public function getErrorMessage()
{
$title = strip_tags("'". ($this->Title ? $this->Title : $this->Name) . "'");
$standard = _t('SilverStripe\\Forms\\Form.FIELDISREQUIRED', '{name} is required.', ['name' => $title]);
$standard = _t(__CLASS__ . '.FIELDISREQUIRED', '{name} is required', ['name' => $title]);
// only use CustomErrorMessage if it has a non empty value
$errorMessage = (!empty($this->CustomErrorMessage)) ? $this->CustomErrorMessage : $standard;

View File

@ -55,7 +55,7 @@ class EditableDateField extends EditableFormField
public function getFormField()
{
$defaultValue = $this->DefaultToToday
? DBDatetime::now()->Format('Y-m-d')
? DBDatetime::now()->Format('yyyy-MM-dd')
: $this->Default;
$field = FormField::create($this->Name, $this->Title ?: false, $defaultValue)

View File

@ -234,12 +234,17 @@ class EmailRecipient extends DataObject
->getRequest()
->setSession(Controller::curr()->getRequest()->getSession());
// If used in a regular page context, will have "/edit" on the end, if used in a trait context
// it won't. Strip that off in case.
$currentUrl = Controller::curr()->getRequest()->getURL();
if (substr($currentUrl, -5) === '/edit') {
$currentUrl = substr($currentUrl, 0, strlen($currentUrl) - 5);
}
$previewUrl = Controller::join_links($currentUrl, 'preview');
$preview = sprintf(
'<p><a href="%s" target="_blank" class="btn btn-outline-secondary">%s</a></p><em>%s</em>',
Controller::join_links(
$pageEditController->getEditForm()->FormAction(),
"field/EmailRecipients/item/{$this->ID}/preview"
),
$previewUrl,
_t('SilverStripe\\UserForms\\Model\\UserDefinedForm.PREVIEW_EMAIL', 'Preview email'),
_t(
'SilverStripe\\UserForms\\Model\\UserDefinedForm.PREVIEW_EMAIL_DESCRIPTION',

View File

@ -3,7 +3,9 @@
namespace SilverStripe\UserForms\Model\Submission;
use SilverStripe\ORM\DataObject;
use SilverStripe\UserForms\Model\Submission\SubmittedForm;
use SilverStripe\ORM\FieldType\DBField;
use SilverStripe\Security\Member;
use SilverStripe\UserForms\Model\EditableFormField;
/**
* Data received from a UserDefinedForm submission
@ -27,10 +29,6 @@ class SubmittedFormField extends DataObject
'FormattedValue' => 'Value'
];
private static $casting = [
'FormattedValue' => 'HTMLFragment'
];
private static $table_name = 'SubmittedFormField';
/**
@ -76,20 +74,20 @@ class SubmittedFormField extends DataObject
/**
* Generate a formatted value for the reports and email notifications.
* Converts new lines (which are stored in the database text field) as
* <brs> so they will output as newlines in the reports
* <brs> so they will output as newlines in the reports.
*
* @return string
* @return DBField
*/
public function getFormattedValue()
{
return nl2br($this->dbObject('Value')->ATT());
return $this->dbObject('Value');
}
/**
* Return the value of this submitted form field suitable for inclusion
* into the CSV
*
* @return Text
* @return DBField
*/
public function getExportValue()
{

View File

@ -3,8 +3,6 @@ en:
SELECTUPLOADFOLDER: 'Select upload folder'
SilverStripe\CMS\Model\SiteTree:
TABMAIN: Main
SilverStripe\Forms\Form:
FIELDISREQUIRED: '{name} is required.'
SilverStripe\UserForms:
ADDEMAILRECIPIENT: 'Add Email Recipient'
CLEARBUTTON: Clear
@ -57,6 +55,7 @@ en:
EXTRACLASS_SELECT: 'Select from the list of allowed styles'
EXTRACLASS_TITLE: 'Extra Styling/Layout'
EXTRACLASS_Title: 'Extra CSS classes'
FIELDISREQUIRED: '{name} is required'
GROUP: Group
INITIALVISIBILITY: 'Initial visibility'
MERGEFIELDNAME: 'Merge field'
@ -148,6 +147,8 @@ en:
one: 'A Page Break'
other: '{count} Page Breaks'
SINGULARNAME: 'Page Break'
STEP_NEXT: Next
STEP_PREV: Prev
STEP_TITLE: 'Page {page}'
TITLE_FIRST: 'First Page'
SilverStripe\UserForms\Model\EditableFormField\EditableLiteralField:

View File

@ -5,10 +5,14 @@
so the 'prev' and 'next' button are not used. These buttons are made visible via JavaScript.
--%>
<li class="step-button-wrapper" aria-hidden="true" style="display:none;">
<button class="step-button-prev">Prev</button>
<button class="step-button-prev">
<%t SilverStripe\\UserForms\\Model\\EditableFormField\\EditableFormStep.STEP_PREV "Prev" %>
</button>
</li>
<li class="step-button-wrapper" aria-hidden="true" style="display:none;">
<button class="step-button-next">Next</button>
<button class="step-button-next">
<%t SilverStripe\\UserForms\\Model\\EditableFormField\\EditableFormStep.STEP_NEXT "Next" %>
</button>
</li>
<% if $Actions %>