mirror of
https://github.com/silverstripe/silverstripe-userforms.git
synced 2024-10-22 17:05:42 +02:00
API Stop using deprecated API
This commit is contained in:
parent
f3f23351a7
commit
7a6cd1c211
@ -56,7 +56,7 @@ class UserFormFieldEditorExtension extends DataExtension
|
|||||||
{
|
{
|
||||||
$fieldEditor = $this->getFieldEditorGrid();
|
$fieldEditor = $this->getFieldEditorGrid();
|
||||||
|
|
||||||
$fields->insertAfter(new Tab('FormFields', _t(__CLASS__.'.FORMFIELDS', 'Form Fields')), 'Main');
|
$fields->insertAfter('Main', new Tab('FormFields', _t(__CLASS__.'.FORMFIELDS', 'Form Fields')));
|
||||||
$fields->addFieldToTab('Root.FormFields', $fieldEditor);
|
$fields->addFieldToTab('Root.FormFields', $fieldEditor);
|
||||||
|
|
||||||
return $fields;
|
return $fields;
|
||||||
@ -192,7 +192,7 @@ class UserFormFieldEditorExtension extends DataExtension
|
|||||||
foreach ($this->owner->Fields() as $field) {
|
foreach ($this->owner->Fields() as $field) {
|
||||||
// store any IDs of fields we publish so we don't unpublish them
|
// store any IDs of fields we publish so we don't unpublish them
|
||||||
$seenIDs[] = $field->ID;
|
$seenIDs[] = $field->ID;
|
||||||
$field->doPublish(Versioned::DRAFT, Versioned::LIVE);
|
$field->publishRecursive();
|
||||||
$field->destroy();
|
$field->destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -291,7 +291,7 @@ class UserFormFieldEditorExtension extends DataExtension
|
|||||||
public function onAfterRevertToLive()
|
public function onAfterRevertToLive()
|
||||||
{
|
{
|
||||||
foreach ($this->owner->Fields() as $field) {
|
foreach ($this->owner->Fields() as $field) {
|
||||||
$field->copyVersionToStage(Versioned::LIVE, Versioned::DRAFT, false);
|
$field->copyVersionToStage(Versioned::LIVE, Versioned::DRAFT);
|
||||||
$field->writeWithoutVersion();
|
$field->writeWithoutVersion();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -265,8 +265,8 @@ class EditableFileField extends EditableFormField
|
|||||||
*/
|
*/
|
||||||
public static function get_php_max_file_size()
|
public static function get_php_max_file_size()
|
||||||
{
|
{
|
||||||
$maxUpload = File::ini2bytes(ini_get('upload_max_filesize'));
|
$maxUpload = Convert::memstring2bytes(ini_get('upload_max_filesize'));
|
||||||
$maxPost = File::ini2bytes(ini_get('post_max_size'));
|
$maxPost = Convert::memstring2bytes(ini_get('post_max_size'));
|
||||||
return min($maxUpload, $maxPost);
|
return min($maxUpload, $maxPost);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,16 +116,13 @@ class EditableMultipleOptionField extends EditableFormField
|
|||||||
* Duplicate a pages content. We need to make sure all the fields attached
|
* Duplicate a pages content. We need to make sure all the fields attached
|
||||||
* to that page go with it
|
* to that page go with it
|
||||||
*
|
*
|
||||||
|
* @param bool $doWrite @deprecated
|
||||||
|
* @param string $manyMany @deprecated
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function duplicate($doWrite = true, $manyMany = 'many_many')
|
public function duplicate($doWrite = true, $manyMany = 'many_many')
|
||||||
{
|
{
|
||||||
// Versioned 1.0 has a bug where [] will result in _all_ relations being duplicated
|
$clonedNode = parent::duplicate(true);
|
||||||
if ($manyMany === 'many_many' && !$this->manyMany()) {
|
|
||||||
$manyMany = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
$clonedNode = parent::duplicate(true, $manyMany);
|
|
||||||
|
|
||||||
foreach ($this->Options() as $field) {
|
foreach ($this->Options() as $field) {
|
||||||
/** @var EditableOption $newField */
|
/** @var EditableOption $newField */
|
||||||
|
@ -332,12 +332,12 @@ class EmailRecipient extends DataObject
|
|||||||
|
|
||||||
if ($templates) {
|
if ($templates) {
|
||||||
$fields->insertBefore(
|
$fields->insertBefore(
|
||||||
|
'EmailBodyHtml',
|
||||||
DropdownField::create(
|
DropdownField::create(
|
||||||
'EmailTemplate',
|
'EmailTemplate',
|
||||||
_t('SilverStripe\\UserForms\\Model\\UserDefinedForm.EMAILTEMPLATE', 'Email template'),
|
_t('SilverStripe\\UserForms\\Model\\UserDefinedForm.EMAILTEMPLATE', 'Email template'),
|
||||||
$templates
|
$templates
|
||||||
)->addExtraClass('toggle-html-only'),
|
)->addExtraClass('toggle-html-only')
|
||||||
'EmailBodyHtml'
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
<nav aria-label="Pages in this form">
|
<nav aria-label="Pages in this form">
|
||||||
<ul class="step-buttons">
|
<ul class="step-buttons">
|
||||||
<% loop $Steps %>
|
<% loop $Steps %>
|
||||||
<li class="step-button-wrapper<% if $First %> current<% end_if %>" data-for="$Name">
|
<li class="step-button-wrapper<% if $IsFirst %> current<% end_if %>" data-for="$Name">
|
||||||
<%-- Remove js-align class to remove javascript positioning --%>
|
<%-- Remove js-align class to remove javascript positioning --%>
|
||||||
<button class="step-button-jump js-align" disabled="disabled" data-step="$Pos"><% if $Top.ButtonText %>$Top.ButtonText <% end_if %>$Pos</button>
|
<button class="step-button-jump js-align" disabled="disabled" data-step="$Pos"><% if $Top.ButtonText %>$Top.ButtonText <% end_if %>$Pos</button>
|
||||||
</li>
|
</li>
|
||||||
|
@ -24,7 +24,7 @@ class EditableNumericFieldTest extends SapphireTest
|
|||||||
|
|
||||||
$result = $field->validate();
|
$result = $field->validate();
|
||||||
$this->assertFalse($result->isValid(), 'Validation should fail when min is greater than max');
|
$this->assertFalse($result->isValid(), 'Validation should fail when min is greater than max');
|
||||||
$this->assertStringContainsString('Minimum length should be less than the maximum length', $result->serialize());
|
$this->assertStringContainsString('Minimum length should be less than the maximum length', json_encode($result->__serialize()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testValidate()
|
public function testValidate()
|
||||||
|
@ -15,6 +15,7 @@ use SilverStripe\UserForms\Model\EditableFormField\EditableOption;
|
|||||||
use SilverStripe\UserForms\Model\EditableFormField\EditableRadioField;
|
use SilverStripe\UserForms\Model\EditableFormField\EditableRadioField;
|
||||||
use SilverStripe\UserForms\Model\EditableFormField\EditableTextField;
|
use SilverStripe\UserForms\Model\EditableFormField\EditableTextField;
|
||||||
use SilverStripe\UserForms\Model\UserDefinedForm;
|
use SilverStripe\UserForms\Model\UserDefinedForm;
|
||||||
|
use SilverStripe\Dev\Deprecation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @package userforms
|
* @package userforms
|
||||||
@ -62,6 +63,9 @@ class EditableFormFieldTest extends FunctionalTest
|
|||||||
|
|
||||||
public function testCustomRules()
|
public function testCustomRules()
|
||||||
{
|
{
|
||||||
|
if (Deprecation::isEnabled()) {
|
||||||
|
$this->markTestSkipped('Test calls deprecated code');
|
||||||
|
}
|
||||||
$this->logInWithPermission('ADMIN');
|
$this->logInWithPermission('ADMIN');
|
||||||
$form = $this->objFromFixture(UserDefinedForm::class, 'custom-rules-form');
|
$form = $this->objFromFixture(UserDefinedForm::class, 'custom-rules-form');
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ class UserDefinedFormTest extends FunctionalTest
|
|||||||
protected function setUp(): void
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
Email::config()->update('admin_email', 'no-reply@example.com');
|
Email::config()->set('admin_email', 'no-reply@example.com');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testRollbackToVersion()
|
public function testRollbackToVersion()
|
||||||
@ -51,6 +51,7 @@ class UserDefinedFormTest extends FunctionalTest
|
|||||||
|
|
||||||
// @todo
|
// @todo
|
||||||
$this->logInWithPermission('ADMIN');
|
$this->logInWithPermission('ADMIN');
|
||||||
|
/** @var UserDefinedForm|Versioned $form */
|
||||||
$form = $this->objFromFixture(UserDefinedForm::class, 'basic-form-page');
|
$form = $this->objFromFixture(UserDefinedForm::class, 'basic-form-page');
|
||||||
|
|
||||||
$form->SubmitButtonText = 'Button Text';
|
$form->SubmitButtonText = 'Button Text';
|
||||||
@ -66,7 +67,7 @@ class UserDefinedFormTest extends FunctionalTest
|
|||||||
$updated = Versioned::get_one_by_stage(UserDefinedForm::class, 'Stage', "\"UserDefinedForm\".\"ID\" = $form->ID");
|
$updated = Versioned::get_one_by_stage(UserDefinedForm::class, 'Stage', "\"UserDefinedForm\".\"ID\" = $form->ID");
|
||||||
$this->assertEquals($updated->SubmitButtonText, 'Updated Button Text');
|
$this->assertEquals($updated->SubmitButtonText, 'Updated Button Text');
|
||||||
|
|
||||||
$form->doRollbackTo($origVersion);
|
$form->rollbackRecursive($origVersion);
|
||||||
|
|
||||||
$orignal = Versioned::get_one_by_stage(UserDefinedForm::class, 'Stage', "\"UserDefinedForm\".\"ID\" = $form->ID");
|
$orignal = Versioned::get_one_by_stage(UserDefinedForm::class, 'Stage', "\"UserDefinedForm\".\"ID\" = $form->ID");
|
||||||
$this->assertEquals($orignal->SubmitButtonText, 'Button Text');
|
$this->assertEquals($orignal->SubmitButtonText, 'Button Text');
|
||||||
@ -521,7 +522,7 @@ class UserDefinedFormTest extends FunctionalTest
|
|||||||
{
|
{
|
||||||
// Test that the $UserDefinedForm is stripped out
|
// Test that the $UserDefinedForm is stripped out
|
||||||
$page = $this->objFromFixture(UserDefinedForm::class, 'basic-form-page');
|
$page = $this->objFromFixture(UserDefinedForm::class, 'basic-form-page');
|
||||||
$page->publish('Stage', 'Live');
|
$page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
||||||
|
|
||||||
$result = $this->get($page->Link());
|
$result = $this->get($page->Link());
|
||||||
$body = Convert::nl2os($result->getBody(), ''); // strip out newlines
|
$body = Convert::nl2os($result->getBody(), ''); // strip out newlines
|
||||||
|
Loading…
Reference in New Issue
Block a user