diff --git a/.upgrade.yml b/.upgrade.yml
index ec1dfa318..c48c0cdc5 100644
--- a/.upgrade.yml
+++ b/.upgrade.yml
@@ -290,8 +290,6 @@ mappings:
CheckboxSetField: SilverStripe\Forms\CheckboxSetField
CompositeField: SilverStripe\Forms\CompositeField
ConfirmedPasswordField: SilverStripe\Forms\ConfirmedPasswordField
- CountryDropdownField: SilverStripe\Forms\CountryDropdownField
- CreditCardField: SilverStripe\Forms\CreditCardField
CurrencyField: SilverStripe\Forms\CurrencyField
CurrencyField_Readonly: SilverStripe\Forms\CurrencyField_Readonly
CurrencyField_Disabled: SilverStripe\Forms\CurrencyField_Disabled
@@ -317,13 +315,10 @@ mappings:
GroupedDropdownField: SilverStripe\Forms\GroupedDropdownField
HeaderField: SilverStripe\Forms\HeaderField
HiddenField: SilverStripe\Forms\HiddenField
- InlineFormAction: SilverStripe\Forms\InlineFormAction
- InlineFormAction_ReadOnly: SilverStripe\Forms\InlineFormAction_ReadOnly
LabelField: SilverStripe\Forms\LabelField
ListboxField: SilverStripe\Forms\ListboxField
LiteralField: SilverStripe\Forms\LiteralField
LookupField: SilverStripe\Forms\LookupField
- MemberDatetimeOptionsetField: SilverStripe\Forms\MemberDatetimeOptionsetField
MoneyField: SilverStripe\Forms\MoneyField
MultiSelectField: SilverStripe\Forms\MultiSelectField
NullableField: SilverStripe\Forms\NullableField
@@ -331,7 +326,6 @@ mappings:
NumericField_Readonly: SilverStripe\Forms\NumericField_Readonly
OptionsetField: SilverStripe\Forms\OptionsetField
PasswordField: SilverStripe\Forms\PasswordField
- PhoneNumberField: SilverStripe\Forms\PhoneNumberField
PopoverField: SilverStripe\Forms\PopoverField
PrintableTransformation: SilverStripe\Forms\PrintableTransformation
PrintableTransformation_TabSet: SilverStripe\Forms\PrintableTransformation_TabSet
@@ -636,7 +630,6 @@ mappings:
GridFieldTest_HTMLFragments: SilverStripe\Forms\Tests\GridField\GridFieldTest\HTMLFragments
GridFieldTest_Permissions: SilverStripe\Forms\Tests\GridField\GridFieldTest\Permissions
GroupedDropdownFieldTest: SilverStripe\Forms\Tests\GroupedDropdownFieldTest
- InlineFormActionTest: SilverStripe\Forms\Tests\InlineFormActionTest
ListboxFieldTest: SilverStripe\Forms\Tests\ListboxFieldTest
ListboxFieldTest_DataObject: SilverStripe\Forms\Tests\ListboxFieldTest\TestObject
ListboxFieldTest_Article: SilverStripe\Forms\Tests\ListboxFieldTest\Article
diff --git a/docs/en/02_Developer_Guides/03_Forms/Field_types/01_Common_Subclasses.md b/docs/en/02_Developer_Guides/03_Forms/Field_types/01_Common_Subclasses.md
index f2b0224ac..cec1603df 100644
--- a/docs/en/02_Developer_Guides/03_Forms/Field_types/01_Common_Subclasses.md
+++ b/docs/en/02_Developer_Guides/03_Forms/Field_types/01_Common_Subclasses.md
@@ -22,10 +22,7 @@ on the SilverStripe API documentation.
## Formatted input
- * [api:AjaxUniqueTextField]: Text field that automatically checks that the value entered is unique for the given set of fields in a given set of tables.
* [api:ConfirmedPasswordField]: Two masked input fields, checks for matching passwords.
- * [api:CountryDropdownField]: A simple extension to dropdown field, pre-configured to list countries.
- * [api:CreditCardField]: Allows input of credit card numbers via four separate form fields, including generic validation of its numeric values.
* [api:CurrencyField]: Text field, validating its input as a currency. Limited to US-centric formats, including a hardcoded currency symbol and decimal separators.
See [api:MoneyField] for a more flexible implementation.
* [api:DateField]: Represents a date in a single input field, or separated into day, month, and year. Can optionally use a calendar popup.
@@ -36,7 +33,6 @@ on the SilverStripe API documentation.
* [api:MoneyField]: A form field that can save into a [api:Money] database field.
* [api:NumericField]: Text input field with validation for numeric values.
* [api:OptionsetField]: Set of radio buttons designed to emulate a dropdown.
- * [api:PhoneNumberField]: Field for displaying phone numbers. It separates the number, the area code and optionally the country code and extension.
* [api:SelectionGroup]: SelectionGroup represents a number of fields which are selectable by a radio button that appears at the beginning of each item.
* [api:TimeField]: Input field with time-specific, localised validation.
diff --git a/docs/en/04_Changelogs/4.0.0.md b/docs/en/04_Changelogs/4.0.0.md
index 362c1d3e4..807436e9d 100644
--- a/docs/en/04_Changelogs/4.0.0.md
+++ b/docs/en/04_Changelogs/4.0.0.md
@@ -1283,6 +1283,9 @@ After (`mysite/_config/config.yml`):
- `getModules`
- `getConfigDirs`
- `getConfigs`
+* Removed `CreditCardField`, `CountryDropdownField`, `PhoneNumberField`, `MemberDatetimeOptionsetField`, `InlineFormAction`.
+ Use custom code instead
+* Removed `ResetFormAction`, use `FormAction::create()->setAttribute('type', 'reset')` instead
#### General and Core Deprecated API
@@ -1816,4 +1819,4 @@ New `TimeField` methods replace `getConfig()` / `setConfig()`
you will need to define this method and return a short name describing the login method.
* `MemberLoginForm` has a new constructor argument for the authenticator class, athough tis is usually
constructed by `MemberAuthenticator` and won't affect normal use.
- * `Authenticator` methods `register` and `unregister` are deprecated in favor of using `Config`
\ No newline at end of file
+ * `Authenticator` methods `register` and `unregister` are deprecated in favor of using `Config`
diff --git a/lang/en.yml b/lang/en.yml
index bc0dc618b..4d6c4da3a 100644
--- a/lang/en.yml
+++ b/lang/en.yml
@@ -53,7 +53,6 @@ en:
BAD_METHOD: 'This form requires a {method} submission'
CSRF_EXPIRED_MESSAGE: 'Your session has expired. Please re-submit the form.'
CSRF_FAILED_MESSAGE: 'There seems to have been a technical problem. Please click the back button, refresh your browser, and try again.'
- VALIDATIONCREDIT: 'Please ensure you have entered the credit card number correctly'
VALIDATIONPASSWORDSDONTMATCH: 'Passwords don''t match'
VALIDATIONPASSWORDSNOTEMPTY: 'Passwords can''t be empty'
VALIDATIONSTRONGPASSWORD: 'Passwords must have at least one digit and one alphanumeric character'
@@ -161,8 +160,6 @@ en:
IsNullLabel: 'Is Null'
SilverStripe\Forms\NumericField:
VALIDATION: '''{value}'' is not a number, only numbers can be accepted for this field'
- SilverStripe\Forms\PhoneNumberField:
- VALIDATION: 'Please enter a valid phone number'
SilverStripe\Forms\TimeField:
VALIDATEFORMAT: 'Please enter a valid time format ({format})'
SilverStripe\ORM\DataObject:
diff --git a/src/Forms/CountryDropdownField.php b/src/Forms/CountryDropdownField.php
deleted file mode 100644
index 54ae894e6..000000000
--- a/src/Forms/CountryDropdownField.php
+++ /dev/null
@@ -1,82 +0,0 @@
-Locale) {
- return $member->Locale;
- }
- return i18n::get_locale();
- }
-
- public function setSource($source)
- {
- if ($source) {
- return parent::setSource($source);
- }
-
- // Get sorted countries
- $source = i18n::getData()->getCountries();
- return parent::setSource($source);
- }
-
- public function Field($properties = array())
- {
- $source = $this->getSource();
-
- // Default value to best availabel locale
- $value = $this->Value();
- if (CountryDropdownField::config()->default_to_locale
- && (!$value || !isset($source[$value]))
- && $this->locale()
- ) {
- $value = i18n::getData()->countryFromLocale(i18n::get_locale());
- if ($value) {
- $this->setValue($value);
- }
- }
-
- // Default to default country otherwise
- if (!$value || !isset($source[$value])) {
- $this->setValue(CountryDropdownField::config()->default_country);
- }
-
- return parent::Field($properties);
- }
-}
diff --git a/src/Forms/CreditCardField.php b/src/Forms/CreditCardField.php
deleted file mode 100644
index cf96689e5..000000000
--- a/src/Forms/CreditCardField.php
+++ /dev/null
@@ -1,121 +0,0 @@
- 'off',
- 'maxlength' => 4,
- 'size' => 4
- )
- );
- }
-
- public function Field($properties = array())
- {
- $parts = $this->arrayValue();
-
- $properties['ValueOne'] = $parts[0];
- $properties['ValueTwo'] = $parts[1];
- $properties['ValueThree'] = $parts[2];
- $properties['ValueFour'] = $parts[3];
-
- return parent::Field($properties);
- }
-
- /**
- * Get tabindex HTML string
- *
- * @param int $increment Increase current tabindex by this value
- * @return string
- */
- public function getTabIndexHTML($increment = 0)
- {
- // we can't add a tabindex if there hasn't been one set yet.
- if ($this->getAttribute('tabindex') === null) {
- return false;
- }
-
- $tabIndex = (int)$this->getAttribute('tabindex') + (int)$increment;
- return (is_numeric($tabIndex)) ? ' tabindex = "' . $tabIndex . '"' : '';
- }
-
- public function dataValue()
- {
- if (is_array($this->value)) {
- return implode("", $this->value);
- } else {
- return $this->value;
- }
- }
-
- /**
- * Get either list of values, or null
- *
- * @return array
- */
- public function arrayValue()
- {
- if (is_array($this->value)) {
- return $this->value;
- }
-
- $value = $this->dataValue();
- return $this->parseCreditCard($value);
- }
-
- /**
- * Parse credit card value into list of four four-digit values
- *
- * @param string $value
- * @return array|null
- */
- protected function parseCreditCard($value)
- {
- if (preg_match("/([0-9]{4})([0-9]{4})([0-9]{4})([0-9]{4})/", $value, $parts)) {
- return [ $parts[1], $parts[2], $parts[3], $parts[4] ];
- }
- return null;
- }
-
- public function validate($validator)
- {
- $value = $this->dataValue();
- if (empty($value)) {
- return true;
- }
-
- // Check if format is valid
- if ($this->parseCreditCard($value)) {
- return true;
- }
-
- // Format is invalid
- $validator->validationError(
- $this->name,
- _t(
- 'SilverStripe\\Forms\\Form.VALIDATIONCREDIT',
- "Please ensure you have entered the credit card number correctly"
- ),
- "validation"
- );
- return false;
- }
-}
diff --git a/src/Forms/FormAction.php b/src/Forms/FormAction.php
index 588f46168..0cc5985d8 100644
--- a/src/Forms/FormAction.php
+++ b/src/Forms/FormAction.php
@@ -175,7 +175,11 @@ class FormAction extends FormField
public function getAttributes()
{
- $type = (isset($this->attributes['src'])) ? 'image' : 'submit';
+ if (isset($this->attributes['type'])) {
+ $type = $this->attributes['type'];
+ } else {
+ $type = (isset($this->attributes['src'])) ? 'image' : 'submit';
+ }
return array_merge(
parent::getAttributes(),
diff --git a/src/Forms/InlineFormAction.php b/src/Forms/InlineFormAction.php
deleted file mode 100644
index a5a83486c..000000000
--- a/src/Forms/InlineFormAction.php
+++ /dev/null
@@ -1,55 +0,0 @@
-extraClass = ' '.$extraClass;
- parent::__construct($action, $title);
- }
-
- public function performReadonlyTransformation()
- {
- return $this->castedCopy('SilverStripe\\Forms\\InlineFormAction_ReadOnly');
- }
-
- /**
- * @param array $properties
- * @return string
- */
- public function Field($properties = array())
- {
- return FormField::create_tag('input', array(
- 'type' => 'submit',
- 'name' => sprintf('action_%s', $this->getName()),
- 'value' => $this->title,
- 'id' => $this->ID(),
- 'class' => sprintf('action%s', $this->extraClass),
- ));
- }
-
- public function Title()
- {
- return false;
- }
-}
diff --git a/src/Forms/InlineFormAction_ReadOnly.php b/src/Forms/InlineFormAction_ReadOnly.php
deleted file mode 100644
index 1573174ef..000000000
--- a/src/Forms/InlineFormAction_ReadOnly.php
+++ /dev/null
@@ -1,33 +0,0 @@
- 'submit',
- 'name' => sprintf('action_%s', $this->name),
- 'value' => $this->title,
- 'id' => $this->ID(),
- 'disabled' => 'disabled',
- 'class' => 'action disabled ' . $this->extraClass,
- ));
- }
-
- public function Title()
- {
- return false;
- }
-}
diff --git a/src/Forms/PhoneNumberField.php b/src/Forms/PhoneNumberField.php
deleted file mode 100644
index 35a916bac..000000000
--- a/src/Forms/PhoneNumberField.php
+++ /dev/null
@@ -1,279 +0,0 @@
-getChildField('Country');
- }
-
- /**
- * @return NumericField
- */
- public function getAreaField()
- {
- return $this->getChildField('Area');
- }
-
- /**
- * @return NumericField
- */
- public function getNumberField()
- {
- return $this->getChildField('Number');
- }
-
- /**
- * @return NumericField
- */
- public function getExtensionField()
- {
- /** @skipUpgrade */
- return $this->getChildField('Extension');
- }
-
- protected function getChildField($name)
- {
- $endsWith = "[{$name}]";
- foreach ($this->getChildren() as $child) {
-
- /** @var Formfield $child */
- if (substr($child->getName(), 0 - strlen($endsWith)) === $endsWith) {
- return $child;
- }
- }
- return null;
- }
-
- public function __construct(
- $name,
- $title = null,
- $value = '',
- $extension = null,
- $areaCode = null,
- $countryCode = null
- ) {
- $this->areaCode = $areaCode;
- $this->ext = $extension;
- $this->countryCode = $countryCode;
-
- // Build fields
- $fields = new FieldList();
- if ($this->countryCode !== null) {
- $countryField = NumericField::create($name.'[Country]', false, $countryCode, 4)
- ->addExtraClass('phonenumber-field__country');
- $fields->push($countryField);
- }
-
- if ($this->areaCode !== null) {
- $areaField = NumericField::create($name.'[Area]', false, $areaCode, 4)
- ->addExtraClass('phonenumber-field__area');
- $fields->push($areaField);
- }
- $numberField = NumericField::create($name.'[Number]', false, null, 10)
- ->addExtraClass('phonenumber-field__number');
- $fields->push($numberField);
-
- if ($this->ext !== null) {
- $extensionField = NumericField::create($name.'[Extension]', false, $extension, 6)
- ->addExtraClass('phonenumber-field__extension');
- $fields->push($extensionField);
- }
-
- parent::__construct($title, $fields);
-
- $this->setName($name);
- if (isset($value)) {
- $this->setValue($value);
- }
- }
-
- public function setName($name)
- {
- parent::setName($name);
- foreach ($this->getChildren() as $child) {
- /** @var FormField $child */
- $thisName = $child->getName();
- $thisName = preg_replace('/^.*(\[\\w+\\])$/', $name . '\\1', $thisName);
- $child->setName($thisName);
- }
- }
-
- public function hasData()
- {
- return true;
- }
-
- /**
- * @param array $properties
- * @return string
- */
- public function Field($properties = array())
- {
- foreach ($this->getChildren() as $field) {
- /** @var FormField $field */
- $field->setDisabled($this->isDisabled());
- $field->setReadonly($this->IsReadonly());
- $field->setForm($this->getForm());
- }
- return parent::Field($properties);
- }
-
- public function setValue($value, $data = null)
- {
- $this->value = self::joinPhoneNumber($value);
- $parts = $this->parseValue();
- if ($countryField = $this->getCountryField()) {
- $countryField->setValue($parts['Country']);
- }
- if ($areaField = $this->getAreaField()) {
- $areaField->setValue($parts['Area']);
- }
- $this->getNumberField()->setValue($parts['Number']);
- if ($extensionField = $this->getExtensionField()) {
- /** @skipUpgrade */
- $extensionField->setValue($parts['Extension']);
- }
- return $this;
- }
-
- /**
- * Join phone number into a string
- *
- * @param array|string $value Input
- * @return string
- */
- public static function joinPhoneNumber($value)
- {
- if (is_array($value)) {
- $completeNumber = '';
- if (!empty($value['Country'])) {
- $completeNumber .= '+' . $value['Country'];
- }
-
- if (!empty($value['Area'])) {
- $completeNumber .= '(' . $value['Area'] . ')';
- }
-
- $completeNumber .= $value['Number'];
-
- /** @skipUpgrade */
- if (!empty($value['Extension'])) {
- $completeNumber .= '#' . $value['Extension'];
- }
-
- return $completeNumber;
- } else {
- return $value;
- }
- }
-
- /**
- * Returns array with parsed phone format
- *
- * @return array Array with Country, Area, Number, and Extension keys (in order)
- */
- protected function parseValue()
- {
- if (is_array($this->value)) {
- return $this->value;
- }
- // Parse value in form "+ countrycode (areacode) phone # extension"
- $valid = preg_match(
- '/^(?:(?:\+(?\d+))?\s*\((?\d+)\))?\s*(?[0-9A-Za-z]*)\s*(?:[#]\s*(?\d+))?$/',
- $this->value,
- $parts
- );
- if (!$valid) {
- $parts = [];
- }
- /** @skipUpgrade */
- return array(
- 'Country' => isset($parts['Country']) ? $parts['Country'] : '',
- 'Area' => isset($parts['Area']) ? $parts['Area'] : '',
- 'Number' => isset($parts['Number']) ? $parts['Number'] : '',
- 'Extension' => isset($parts['Extension']) ? $parts['Extension'] : '',
- );
- }
-
- public function saveInto(DataObjectInterface $record)
- {
- $completeNumber = static::joinPhoneNumber($this->parseValue());
- $record->setCastedField($this->getName(), $completeNumber);
- }
-
- /**
- * Validate this field
- *
- * @todo Very basic validation at the moment
- *
- * @param Validator $validator
- * @return bool
- */
- public function validate($validator)
- {
- $valid = preg_match(
- '/^[0-9\+\-\(\)\s\#]*$/',
- $this->joinPhoneNumber($this->value)
- );
-
- if (!$valid) {
- $validator->validationError(
- $this->name,
- _t('SilverStripe\\Forms\\PhoneNumberField.VALIDATION', "Please enter a valid phone number"),
- "validation"
- );
- return false;
- }
-
- return true;
- }
-
- public function performReadonlyTransformation()
- {
- // Just setReadonly without casting to NumericField_Readonly
- $clone = clone $this;
- $clone->setReadonly(true);
- return $clone;
- }
-
- public function performDisabledTransformation()
- {
- // Just setDisabled without casting to NumericField_Disabled
- $clone = clone $this;
- $clone->setDisabled(true);
- return $clone;
- }
-}
diff --git a/src/Forms/ResetFormAction.php b/src/Forms/ResetFormAction.php
deleted file mode 100644
index 7939f38e3..000000000
--- a/src/Forms/ResetFormAction.php
+++ /dev/null
@@ -1,24 +0,0 @@
- 'reset')
- );
- }
-
- public function Type()
- {
- return 'resetformaction';
- }
-}
diff --git a/templates/SilverStripe/Forms/CreditCardField.ss b/templates/SilverStripe/Forms/CreditCardField.ss
deleted file mode 100644
index 61ab1e186..000000000
--- a/templates/SilverStripe/Forms/CreditCardField.ss
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
- -
-
- -
-
- -
-
-
diff --git a/tests/php/Forms/InlineFormActionTest.php b/tests/php/Forms/InlineFormActionTest.php
deleted file mode 100644
index 515ef1e7e..000000000
--- a/tests/php/Forms/InlineFormActionTest.php
+++ /dev/null
@@ -1,25 +0,0 @@
-Field();
- $this->assertContains('assertContains('type="submit"', $html);
- $this->assertContains('name="action_dothing"', $html);
- $this->assertContains('value="My Title"', $html);
- $this->assertContains('id="dothing"', $html);
- $this->assertContains('class="action ss-action"', $html);
- }
-}