diff --git a/forms/CheckboxField.php b/forms/CheckboxField.php index e88f7ca3c..b2a2895ac 100644 --- a/forms/CheckboxField.php +++ b/forms/CheckboxField.php @@ -7,6 +7,8 @@ */ class CheckboxField extends FormField { + protected $schemaDataType = FormField::SCHEMA_DATA_TYPE_SINGLESELECT; + public function setValue($value) { $this->value = ($value) ? 1 : 0; return $this; diff --git a/forms/CheckboxSetField.php b/forms/CheckboxSetField.php index 6379c749d..898ffcd9c 100644 --- a/forms/CheckboxSetField.php +++ b/forms/CheckboxSetField.php @@ -38,6 +38,8 @@ */ class CheckboxSetField extends MultiSelectField { + protected $schemaDataType = FormField::SCHEMA_DATA_TYPE_MULTISELECT; + /** * @todo Explain different source data that can be used with this field, * e.g. SQLMap, ArrayList or an array. diff --git a/forms/CompositeField.php b/forms/CompositeField.php index f137b25e1..7aa7b3ac2 100644 --- a/forms/CompositeField.php +++ b/forms/CompositeField.php @@ -43,6 +43,8 @@ class CompositeField extends FormField { */ protected $legend; + protected $schemaDataType = FormField::SCHEMA_DATA_TYPE_STRUCTURAL; + public function __construct($children = null) { if($children instanceof FieldList) { $this->children = $children; @@ -394,4 +396,3 @@ class CompositeField extends FormField { } } - diff --git a/forms/ConfirmedPasswordField.php b/forms/ConfirmedPasswordField.php index ce426708d..e5e32fc47 100644 --- a/forms/ConfirmedPasswordField.php +++ b/forms/ConfirmedPasswordField.php @@ -75,6 +75,8 @@ class ConfirmedPasswordField extends FormField { */ public $children; + protected $schemaDataType = FormField::SCHEMA_DATA_TYPE_STRUCTURAL; + /** * @param string $name * @param string $title diff --git a/forms/CountryDropdownField.php b/forms/CountryDropdownField.php index e68dd063d..b8ca28af3 100644 --- a/forms/CountryDropdownField.php +++ b/forms/CountryDropdownField.php @@ -28,6 +28,8 @@ class CountryDropdownField extends DropdownField { protected $extraClasses = array('dropdown'); + protected $schemaDataType = FormField::SCHEMA_DATA_TYPE_SINGLESELECT; + /** * Get the locale of the Member, or if we're not logged in or don't have a locale, use the default one * @return string diff --git a/forms/CurrencyField.php b/forms/CurrencyField.php index 96a8842be..baef6c8bd 100644 --- a/forms/CurrencyField.php +++ b/forms/CurrencyField.php @@ -112,4 +112,3 @@ class CurrencyField_Disabled extends CurrencyField{ . " name=\"".$this->name."\" value=\"".$valforInput."\" />"; } } - diff --git a/forms/DateField.php b/forms/DateField.php index 90065b7d7..ab6874581 100644 --- a/forms/DateField.php +++ b/forms/DateField.php @@ -60,6 +60,8 @@ require_once 'Zend/Date.php'; */ class DateField extends TextField { + protected $schemaDataType = FormField::SCHEMA_DATA_TYPE_DATE; + /** * @config * @var array @@ -677,4 +679,3 @@ class DateField_View_JQuery extends Object { return preg_replace($patterns, $replacements, $format); } } - diff --git a/forms/DatetimeField.php b/forms/DatetimeField.php index e57847ef7..e34ac4f6a 100644 --- a/forms/DatetimeField.php +++ b/forms/DatetimeField.php @@ -44,6 +44,8 @@ class DatetimeField extends FormField { */ protected $timeField = null; + protected $schemaDataType = FormField::SCHEMA_DATA_TYPE_DATETIME; + /** * @config * @var array diff --git a/forms/FormField.php b/forms/FormField.php index 9b0711338..982274537 100644 --- a/forms/FormField.php +++ b/forms/FormField.php @@ -29,6 +29,48 @@ */ class FormField extends RequestHandler { + /** @see $schemaDataType */ + const SCHEMA_DATA_TYPE_STRING = 'String'; + + /** @see $schemaDataType */ + const SCHEMA_DATA_TYPE_HIDDEN = 'Hidden'; + + /** @see $schemaDataType */ + const SCHEMA_DATA_TYPE_TEXT = 'Text'; + + /** @see $schemaDataType */ + const SCHEMA_DATA_TYPE_HTML = 'HTML'; + + /** @see $schemaDataType */ + const SCHEMA_DATA_TYPE_INTEGER = 'Integer'; + + /** @see $schemaDataType */ + const SCHEMA_DATA_TYPE_DECIMAL = 'Decimal'; + + /** @see $schemaDataType */ + const SCHEMA_DATA_TYPE_MULTISELECT = 'MultiSelect'; + + /** @see $schemaDataType */ + const SCHEMA_DATA_TYPE_SINGLESELECT = 'SingleSelect'; + + /** @see $schemaDataType */ + const SCHEMA_DATA_TYPE_DATE = 'Date'; + + /** @see $schemaDataType */ + const SCHEMA_DATA_TYPE_DATETIME = 'DateTime'; + + /** @see $schemaDataType */ + const SCHEMA_DATA_TYPE_TIME = 'Time'; + + /** @see $schemaDataType */ + const SCHEMA_DATA_TYPE_BOOLEAN = 'Boolean'; + + /** @see $schemaDataType */ + const SCHEMA_DATA_TYPE_CUSTOM = 'Custom'; + + /** @see $schemaDataType */ + const SCHEMA_DATA_TYPE_STRUCTURAL = 'Structural'; + /** * @var Form */ @@ -170,7 +212,7 @@ class FormField extends RequestHandler { /** * The data type backing the field. Represents the type of value the - * form expects to receive via a postback. + * form expects to receive via a postback. Should be set in subclasses. * * The values allowed in this list include: * @@ -192,6 +234,8 @@ class FormField extends RequestHandler { * or simply be a block of stand-alone content. As with 'Custom', * the component property is mandatory if this is assigned. * + * Each value has an equivalent constant, e.g. {@link self::SCHEMA_DATA_TYPE_STRING}. + * * @var string */ protected $schemaDataType; diff --git a/forms/HiddenField.php b/forms/HiddenField.php index 052d97d5d..d03f76b18 100644 --- a/forms/HiddenField.php +++ b/forms/HiddenField.php @@ -7,6 +7,9 @@ * @subpackage fields-dataless */ class HiddenField extends FormField { + + protected $schemaDataType = FormField::SCHEMA_DATA_TYPE_HIDDEN; + /** * @param array $properties * diff --git a/forms/MoneyField.php b/forms/MoneyField.php index d8c4f15fa..5d5161a88 100644 --- a/forms/MoneyField.php +++ b/forms/MoneyField.php @@ -15,6 +15,8 @@ use SilverStripe\Model\FieldType\DBMoney; */ class MoneyField extends FormField { + protected $schemaDataType = FormField::SCHEMA_DATA_TYPE_TEXT; + /** * @var string $_locale */ diff --git a/forms/MultiSelectField.php b/forms/MultiSelectField.php index be1354088..15ba9f16d 100644 --- a/forms/MultiSelectField.php +++ b/forms/MultiSelectField.php @@ -15,6 +15,8 @@ abstract class MultiSelectField extends SelectField { */ protected $defaultItems = array(); + protected $schemaDataType = FormField::SCHEMA_DATA_TYPE_MULTISELECT; + /** * Extracts the value of this field, normalised as an array. * Scalar values will return a single length array, even if empty diff --git a/forms/NumericField.php b/forms/NumericField.php index 6a40c2778..39616cb4c 100644 --- a/forms/NumericField.php +++ b/forms/NumericField.php @@ -9,6 +9,9 @@ * @subpackage fields-formattedinput */ class NumericField extends TextField { + + protected $schemaDataType = FormField::SCHEMA_DATA_TYPE_DECIMAL; + /** * Override locale for this field. * diff --git a/forms/SingleSelectField.php b/forms/SingleSelectField.php index 186e006bf..567688fda 100644 --- a/forms/SingleSelectField.php +++ b/forms/SingleSelectField.php @@ -23,6 +23,8 @@ abstract class SingleSelectField extends SelectField { */ protected $emptyString = ''; + protected $schemaDataType = FormField::SCHEMA_DATA_TYPE_SINGLESELECT; + /** * @param boolean $bool * @return self Self reference diff --git a/forms/Tab.php b/forms/Tab.php index 3773528d2..14d53b5e1 100644 --- a/forms/Tab.php +++ b/forms/Tab.php @@ -82,4 +82,3 @@ class Tab extends CompositeField { ); } } - diff --git a/forms/TextField.php b/forms/TextField.php index f374500f8..e14ef47ef 100644 --- a/forms/TextField.php +++ b/forms/TextField.php @@ -12,6 +12,8 @@ class TextField extends FormField { */ protected $maxLength; + protected $schemaDataType = FormField::SCHEMA_DATA_TYPE_TEXT; + /** * Returns an input field. * diff --git a/forms/TimeField.php b/forms/TimeField.php index 0dc023274..6dc7c754e 100644 --- a/forms/TimeField.php +++ b/forms/TimeField.php @@ -50,6 +50,8 @@ class TimeField extends TextField { */ protected $valueObj = null; + protected $schemaDataType = FormField::SCHEMA_DATA_TYPE_TIME; + public function __construct($name, $title = null, $value = ""){ if(!$this->locale) { $this->locale = i18n::get_locale();