mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-06-26 06:29:24 +02:00
Merge remote-tracking branch 'refs/remotes/chillu/formfield-constructors'
Conflicts: forms/CountryDropdownField.php
This commit is contained in:
commit
7c6050b407
|
@ -84,6 +84,14 @@ as well as the HTML form element itself.
|
||||||
<input type="checkbox" class="checkbox extraClass".../>
|
<input type="checkbox" class="checkbox extraClass".../>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
### FormField constructor argument changes ###
|
||||||
|
|
||||||
|
In order to enforce a consistent parameter order in core [api:FormField] subclasses,
|
||||||
|
its no longer possible to set the following optional attributes via constructor arguments:
|
||||||
|
`$form`, `$maxLength`, `$rightTitle`, `$rows`/`$cols` (for `TextareaField` and `HtmlEditorField`)
|
||||||
|
and `$folderName` (for `FileField` and `SimpleImageField`).
|
||||||
|
Please use the appropriate setters on the form field instance instead.
|
||||||
|
|
||||||
### Restructured files and folders ###
|
### Restructured files and folders ###
|
||||||
|
|
||||||
In order to make the `sapphire` framework useable without the `cms` module,
|
In order to make the `sapphire` framework useable without the `cms` module,
|
||||||
|
@ -143,4 +151,4 @@ Alternatively, you can enforce database usage by setting `SapphireTest->usesData
|
||||||
* `Archive`, `TarballArchive`: If you make use of these, copy the classes from 2.4 into your project.
|
* `Archive`, `TarballArchive`: If you make use of these, copy the classes from 2.4 into your project.
|
||||||
* `XML`: Use PHP's built-in SimpleXML instead
|
* `XML`: Use PHP's built-in SimpleXML instead
|
||||||
* `DataObjectLog`: There is no replacement for this.
|
* `DataObjectLog`: There is no replacement for this.
|
||||||
* `GeoIP`: Moved to separate ["geoip" module](https://github.com/silverstripe-labs/silverstripe-geoip)
|
* `GeoIP`: Moved to separate ["geoip" module](https://github.com/silverstripe-labs/silverstripe-geoip)
|
||||||
|
|
|
@ -87,7 +87,7 @@ class DateField extends TextField {
|
||||||
*/
|
*/
|
||||||
protected $valueObj = null;
|
protected $valueObj = null;
|
||||||
|
|
||||||
function __construct($name, $title = null, $value = null, $form = null, $rightTitle = null) {
|
function __construct($name, $title = null, $value = null) {
|
||||||
if(!$this->locale) {
|
if(!$this->locale) {
|
||||||
$this->locale = i18n::get_locale();
|
$this->locale = i18n::get_locale();
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,15 +101,13 @@ class FileField extends FormField {
|
||||||
* @param string $name The internal field name, passed to forms.
|
* @param string $name The internal field name, passed to forms.
|
||||||
* @param string $title The field label.
|
* @param string $title The field label.
|
||||||
* @param int $value The value of the field.
|
* @param int $value The value of the field.
|
||||||
* @param Form $form Reference to the container form
|
|
||||||
* @param string $rightTitle Used in SmallFieldHolder() to force a right-aligned label
|
|
||||||
* @param string $folderName Folder to upload files to
|
|
||||||
*/
|
*/
|
||||||
function __construct($name, $title = null, $value = null, $form = null, $rightTitle = null, $folderName = null) {
|
function __construct($name, $title = null, $value = null) {
|
||||||
if(isset($folderName)) $this->folderName = $folderName;
|
if(count(func_get_args()) > 3) Deprecation::notice('3.0', 'Use setRightTitle() and setFolderName() instead of constructor arguments');
|
||||||
|
|
||||||
$this->upload = new Upload();
|
$this->upload = new Upload();
|
||||||
|
|
||||||
parent::__construct($name, $title, $value, $form, $rightTitle);
|
parent::__construct($name, $title, $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function Field($properties = array()) {
|
public function Field($properties = array()) {
|
||||||
|
|
|
@ -100,10 +100,8 @@ class FormField extends RequestHandler {
|
||||||
* @param name The internal field name, passed to forms.
|
* @param name The internal field name, passed to forms.
|
||||||
* @param title The field label.
|
* @param title The field label.
|
||||||
* @param value The value of the field.
|
* @param value The value of the field.
|
||||||
* @param form Reference to the container form
|
|
||||||
* @param maxLength The Maximum length of the attribute
|
|
||||||
*/
|
*/
|
||||||
function __construct($name, $title = null, $value = null, $form = null, $rightTitle = null) {
|
function __construct($name, $title = null, $value = null) {
|
||||||
$this->name = $name;
|
$this->name = $name;
|
||||||
$this->title = ($title === null) ? $name : $title;
|
$this->title = ($title === null) ? $name : $title;
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ class HeaderField extends DatalessField {
|
||||||
*/
|
*/
|
||||||
protected $headingLevel = 2;
|
protected $headingLevel = 2;
|
||||||
|
|
||||||
function __construct($name, $title = null, $headingLevel = 2, $form = null) {
|
function __construct($name, $title = null, $headingLevel = 2) {
|
||||||
// legacy handling for old parameters: $title, $heading, ...
|
// legacy handling for old parameters: $title, $heading, ...
|
||||||
// instead of new handling: $name, $title, $heading, ...
|
// instead of new handling: $name, $title, $heading, ...
|
||||||
$args = func_get_args();
|
$args = func_get_args();
|
||||||
|
@ -29,7 +29,7 @@ class HeaderField extends DatalessField {
|
||||||
|
|
||||||
if($headingLevel) $this->headingLevel = $headingLevel;
|
if($headingLevel) $this->headingLevel = $headingLevel;
|
||||||
|
|
||||||
parent::__construct($name, $title, null, $form);
|
parent::__construct($name, $title);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getHeadingLevel() {
|
public function getHeadingLevel() {
|
||||||
|
|
|
@ -43,8 +43,10 @@ class HtmlEditorField extends TextareaField {
|
||||||
/**
|
/**
|
||||||
* @see TextareaField::__construct()
|
* @see TextareaField::__construct()
|
||||||
*/
|
*/
|
||||||
public function __construct($name, $title = null, $rows = 30, $cols = 20, $value = '', $form = null) {
|
public function __construct($name, $title = null, $value = '') {
|
||||||
parent::__construct($name, $title, $rows, $cols, $value, $form);
|
if(count(func_get_args()) > 3) Deprecation::notice('3.0', 'Use setRows() and setCols() instead of constructor arguments');
|
||||||
|
|
||||||
|
parent::__construct($name, $title, $value);
|
||||||
|
|
||||||
self::include_js();
|
self::include_js();
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ class LabelField extends DatalessField {
|
||||||
* @param string $title
|
* @param string $title
|
||||||
* @param Form $form
|
* @param Form $form
|
||||||
*/
|
*/
|
||||||
function __construct($name, $title, $form = null) {
|
function __construct($name, $title) {
|
||||||
// legacy handling for old parameters: $title, $heading, ...
|
// legacy handling for old parameters: $title, $heading, ...
|
||||||
// instead of new handling: $name, $title, $heading, ...
|
// instead of new handling: $name, $title, $heading, ...
|
||||||
$args = func_get_args();
|
$args = func_get_args();
|
||||||
|
@ -26,7 +26,7 @@ class LabelField extends DatalessField {
|
||||||
$form = (isset($args[3])) ? $args[3] : null;
|
$form = (isset($args[3])) ? $args[3] : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
parent::__construct($name, $title, $form);
|
parent::__construct($name, $title);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -51,10 +51,10 @@ class ListboxField extends DropdownField {
|
||||||
* @param int $size Optional size of the select element
|
* @param int $size Optional size of the select element
|
||||||
* @param form The parent form
|
* @param form The parent form
|
||||||
*/
|
*/
|
||||||
function __construct($name, $title = '', $source = array(), $value = '', $size = null, $multiple = false, $form = null) {
|
function __construct($name, $title = '', $source = array(), $value = '', $size = null, $multiple = false) {
|
||||||
if($size) $this->size = $size;
|
if($size) $this->size = $size;
|
||||||
if($multiple) $this->multiple = $multiple;
|
if($multiple) $this->multiple = $multiple;
|
||||||
parent::__construct($name, $title, $source, $value, $form);
|
parent::__construct($name, $title, $source, $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -32,12 +32,12 @@ class MoneyField extends FormField {
|
||||||
*/
|
*/
|
||||||
protected $fieldCurrency = null;
|
protected $fieldCurrency = null;
|
||||||
|
|
||||||
function __construct($name, $title = null, $value = "", $form = null) {
|
function __construct($name, $title = null, $value = "") {
|
||||||
// naming with underscores to prevent values from actually being saved somewhere
|
// naming with underscores to prevent values from actually being saved somewhere
|
||||||
$this->fieldAmount = new NumericField("{$name}[Amount]", _t('MoneyField.FIELDLABELAMOUNT', 'Amount'));
|
$this->fieldAmount = new NumericField("{$name}[Amount]", _t('MoneyField.FIELDLABELAMOUNT', 'Amount'));
|
||||||
$this->fieldCurrency = $this->FieldCurrency($name);
|
$this->fieldCurrency = $this->FieldCurrency($name);
|
||||||
|
|
||||||
parent::__construct($name, $title, $value, $form);
|
parent::__construct($name, $title, $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -6,20 +6,13 @@
|
||||||
*/
|
*/
|
||||||
class PasswordField extends TextField {
|
class PasswordField extends TextField {
|
||||||
|
|
||||||
/**
|
|
||||||
* maxlength of the password field
|
|
||||||
*
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
protected $maxLength;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an input field, class="text" and type="text" with an optional
|
* Returns an input field, class="text" and type="text" with an optional
|
||||||
* maxlength
|
* maxlength
|
||||||
*/
|
*/
|
||||||
function __construct($name, $title = null, $value = "", $maxLength = null) {
|
function __construct($name, $title = null, $value = "") {
|
||||||
$this->maxLength = $maxLength;
|
if(count(func_get_args()) > 3) Deprecation::notice('3.0', 'Use setMaxLength() instead of constructor arguments');
|
||||||
|
|
||||||
parent::__construct($name, $title, $value);
|
parent::__construct($name, $title, $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,14 +17,13 @@ class PhoneNumberField extends FormField {
|
||||||
protected $countryCode;
|
protected $countryCode;
|
||||||
protected $ext;
|
protected $ext;
|
||||||
|
|
||||||
public function __construct( $name, $title = null, $value = '', $extension = null,
|
public function __construct( $name, $title = null, $value = '', $extension = null, $areaCode = null, $countryCode = null) {
|
||||||
$areaCode = null, $countryCode = null, $form = null ) {
|
|
||||||
|
|
||||||
$this->areaCode = $areaCode;
|
$this->areaCode = $areaCode;
|
||||||
$this->ext = $extension;
|
$this->ext = $extension;
|
||||||
$this->countryCode = $countryCode;
|
$this->countryCode = $countryCode;
|
||||||
|
|
||||||
parent::__construct( $name, $title, $value, $form );
|
parent::__construct($name, $title, $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function Field() {
|
public function Field() {
|
||||||
|
|
|
@ -65,8 +65,10 @@
|
||||||
|
|
||||||
class SimpleImageField extends FileField {
|
class SimpleImageField extends FileField {
|
||||||
|
|
||||||
function __construct($name, $title = null, $value = null, $form = null, $rightTitle = null, $folderName = null) {
|
function __construct($name, $title = null, $value = null) {
|
||||||
parent::__construct($name, $title, $value, $form, $rightTitle, $folderName);
|
if(count(func_get_args()) > 3) Deprecation::notice('3.0', 'Use setRightTitle() and setFolderName() instead of constructor arguments');
|
||||||
|
|
||||||
|
parent::__construct($name, $title, $value);
|
||||||
|
|
||||||
$this->getValidator()->setAllowedExtensions(array('jpg','gif','png'));
|
$this->getValidator()->setAllowedExtensions(array('jpg','gif','png'));
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,15 +31,12 @@ class TextareaField extends FormField {
|
||||||
*
|
*
|
||||||
* @param $name Field name
|
* @param $name Field name
|
||||||
* @param $title Field title
|
* @param $title Field title
|
||||||
* @param $rows The number of rows
|
|
||||||
* @param $cols The number of columns
|
|
||||||
* @param $value The current value
|
* @param $value The current value
|
||||||
* @param $form The parent form. Auto-set when the field is placed in a form.
|
|
||||||
*/
|
*/
|
||||||
function __construct($name, $title = null, $rows = 5, $cols = 20, $value = "", $form = null) {
|
function __construct($name, $title = null, $value = '') {
|
||||||
$this->rows = $rows;
|
if(count(func_get_args()) > 3) Deprecation::notice('3.0', 'Use setRows() and setCols() instead of constructor arguments');
|
||||||
$this->cols = $cols;
|
|
||||||
parent::__construct($name, $title, $value, $form);
|
parent::__construct($name, $title, $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAttributes() {
|
function getAttributes() {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user