code
stringlengths
17
247k
docstring
stringlengths
30
30.3k
func_name
stringlengths
1
89
language
stringclasses
1 value
repo
stringlengths
7
63
path
stringlengths
7
153
url
stringlengths
51
209
license
stringclasses
4 values
protected function csvDecode($value) { if (!$value) { return []; } return preg_split('/\s*,\s*/', trim($value ?? '')); }
Decode a list of values from a comma separated string. Spaces are trimmed @param string $value @return array
csvDecode
php
silverstripe/silverstripe-framework
src/Forms/MultiSelectField.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/MultiSelectField.php
BSD-3-Clause
public function performReadonlyTransformation() { $field = $this->castedCopy('SilverStripe\\Forms\\LookupField'); $field->setSource($this->getSource()); $field->setReadonly(true); // Pass through default items if (!$this->getValueArray() && $this->getDefaultItems()) { $field->setValue($this->getDefaultItems()); } return $field; }
Transforms the source data for this CheckboxSetField into a comma separated list of values. @return ReadonlyField
performReadonlyTransformation
php
silverstripe/silverstripe-framework
src/Forms/MultiSelectField.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/MultiSelectField.php
BSD-3-Clause
public function getIsNullLabel() { return $this->isNullLabel; }
Get the label used for the Is Null checkbox. @return string
getIsNullLabel
php
silverstripe/silverstripe-framework
src/Forms/NullableField.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/NullableField.php
BSD-3-Clause
public function setIsNullLabel($isNulLabel) { $this->isNullLabel = $isNulLabel; return $this; }
Set the label used for the Is Null checkbox. @param $isNulLabel string @return $this
setIsNullLabel
php
silverstripe/silverstripe-framework
src/Forms/NullableField.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/NullableField.php
BSD-3-Clause
public function getIsNullId() { return $this->getName() . "_IsNull"; }
Get the id used for the Is Null check box. @return string
getIsNullId
php
silverstripe/silverstripe-framework
src/Forms/NullableField.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/NullableField.php
BSD-3-Clause
public function setValue($value, $data = null) { $id = $this->getIsNullId(); if (is_array($data) && array_key_exists($id, $data ?? []) && $data[$id]) { $value = null; } $this->valueField->setValue($value); parent::setValue($value); return $this; }
Value is sometimes an array, and sometimes a single value, so we need to handle both cases @param mixed $value @param null|array $data @return $this
setValue
php
silverstripe/silverstripe-framework
src/Forms/NullableField.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/NullableField.php
BSD-3-Clause
public function setEmptyString($string) { $this->setHasEmptyDefault(true); $this->emptyString = $string; return $this; }
Set the default selection label, e.g. "select...". Defaults to an empty string. Automatically sets {@link $hasEmptyDefault} to true. @param string $string @return $this
setEmptyString
php
silverstripe/silverstripe-framework
src/Forms/SingleSelectField.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/SingleSelectField.php
BSD-3-Clause
public function getSourceEmpty() { // Inject default option if ($this->getHasEmptyDefault()) { return ['' => $this->getEmptyString()] + $this->getSource(); } else { return $this->getSource(); } }
Gets the source array, including the empty string, if present @return array|ArrayAccess
getSourceEmpty
php
silverstripe/silverstripe-framework
src/Forms/SingleSelectField.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/SingleSelectField.php
BSD-3-Clause
public function Field($properties = []) { if ($this->value) { $val = Convert::raw2xml($this->value); $val = DBCurrency::config()->get('currency_symbol') . number_format(preg_replace('/[^0-9.-]/', '', $val ?? '') ?? 0.0, 2); $valforInput = Convert::raw2att($val); } else { $valforInput = ''; } return "<input class=\"text\" type=\"text\" disabled=\"disabled\"" . " name=\"" . $this->name . "\" value=\"" . $valforInput . "\" />"; }
Overloaded to display the correctly formatted value for this data type @param array $properties @return string
Field
php
silverstripe/silverstripe-framework
src/Forms/CurrencyField_Disabled.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/CurrencyField_Disabled.php
BSD-3-Clause
public function hasData() { return false; }
function that returns whether this field contains data. Always returns false.
hasData
php
silverstripe/silverstripe-framework
src/Forms/DatalessField.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/DatalessField.php
BSD-3-Clause
public function FieldHolder($properties = []) { return $this->Field($properties); }
Returns the field's representation in the form. For dataless fields, this defaults to $Field. @param array $properties @return DBHTMLText
FieldHolder
php
silverstripe/silverstripe-framework
src/Forms/DatalessField.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/DatalessField.php
BSD-3-Clause
public function SmallFieldHolder($properties = []) { return $this->Field($properties); }
Returns the field's representation in a field group. For dataless fields, this defaults to $Field. @param array $properties @return DBHTMLText
SmallFieldHolder
php
silverstripe/silverstripe-framework
src/Forms/DatalessField.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/DatalessField.php
BSD-3-Clause
public function performReadonlyTransformation() { $clone = clone $this; $clone->setReadonly(true); return $clone; }
Returns a readonly version of this field
performReadonlyTransformation
php
silverstripe/silverstripe-framework
src/Forms/DatalessField.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/DatalessField.php
BSD-3-Clause
public function validate() { $this->resetResult(); if ($this->getEnabled()) { $this->php($this->form->getData()); } return $this->result; }
Returns any errors there may be. @return ValidationResult
validate
php
silverstripe/silverstripe-framework
src/Forms/Validator.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/Validator.php
BSD-3-Clause
public function validationError( $fieldName, $message, $messageType = ValidationResult::TYPE_ERROR, $cast = ValidationResult::CAST_TEXT ) { $this->result->addFieldError($fieldName, $message, $messageType, null, $cast); return $this; }
Callback to register an error on a field (Called from implementations of {@link FormField::validate}). The optional error message type parameter is loaded into the HTML class attribute. See {@link getErrors()} for details. @param string $fieldName Field name for this error @param string $message The message string @param string $messageType The type of message: e.g. "bad", "warning", "good", or "required". Passed as a CSS class to the form, so other values can be used if desired. @param string|bool $cast Cast type; One of the CAST_ constant definitions. Bool values will be treated as plain text flag. @return $this
validationError
php
silverstripe/silverstripe-framework
src/Forms/Validator.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/Validator.php
BSD-3-Clause
public function getErrors() { if ($this->result) { return $this->result->getMessages(); } return null; }
Returns all errors found by a previous call to {@link validate()}. The returned array has a structure resembling: <code> array( 'fieldName' => '[form field name]', 'message' => '[validation error message]', 'messageType' => '[bad|message|validation|required]', 'messageCast' => '[text|html]' ) </code> @return null|array
getErrors
php
silverstripe/silverstripe-framework
src/Forms/Validator.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/Validator.php
BSD-3-Clause
public function fieldIsRequired($fieldName) { return false; }
Returns whether the field in question is required. This will usually display '*' next to the field. The base implementation always returns false. @param string $fieldName @return bool
fieldIsRequired
php
silverstripe/silverstripe-framework
src/Forms/Validator.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/Validator.php
BSD-3-Clause
public function performReadonlyTransformation() { return clone $this; }
This already is a readonly field.
performReadonlyTransformation
php
silverstripe/silverstripe-framework
src/Forms/CurrencyField_Readonly.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/CurrencyField_Readonly.php
BSD-3-Clause
public function __construct($titleOrField = null, $otherFields = null) { $title = null; if (is_array($titleOrField) || $titleOrField instanceof FieldList) { $fields = $titleOrField; // This would be discarded otherwise if ($otherFields) { throw new InvalidArgumentException( '$otherFields is not accepted if passing in field list to $titleOrField' ); } } elseif (is_array($otherFields) || $otherFields instanceof FieldList) { $title = $titleOrField; $fields = $otherFields; } else { $fields = func_get_args(); if (!is_object(reset($fields))) { $title = array_shift($fields); } } parent::__construct($fields); if ($title) { $this->setTitle($title); } }
Create a new field group. Accepts any number of arguments. @param mixed $titleOrField Either the field title, list of fields, or first field @param mixed ...$otherFields Subsequent fields or field list (if passing in title to $titleOrField)
__construct
php
silverstripe/silverstripe-framework
src/Forms/FieldGroup.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/FieldGroup.php
BSD-3-Clause
public function getName() { if ($this->name) { return $this->name; } if (!$this->title) { return parent::getName(); } return preg_replace("/[^a-zA-Z0-9]+/", "", $this->title ?? ''); }
Returns the name (ID) for the element. In some cases the FieldGroup doesn't have a title, but we still want the ID / name to be set. This code, generates the ID from the nested children
getName
php
silverstripe/silverstripe-framework
src/Forms/FieldGroup.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/FieldGroup.php
BSD-3-Clause
public function saveInto(DataObjectInterface $record) { $fieldName = $this->getName(); /** @var Relation $saveDest */ $saveDest = $record->$fieldName(); if (!$saveDest) { $recordClass = get_class($record); throw new \RuntimeException( "TreeMultiselectField::saveInto() Field '$fieldName' not found on" . " {$recordClass}.{$record->ID}" ); } $itemIDs = $this->getItems()->column('ID'); // Allows you to modify the itemIDs on your object before save $funcName = "onChange$fieldName"; if ($record->hasMethod($funcName)) { $result = $record->$funcName($itemIDs); if (!$result) { return; } } $saveDest->setByIDList($itemIDs); }
Save the results into the form Calls function $record->onChange($items) before saving to the assumed Component set. @param DataObjectInterface $record
saveInto
php
silverstripe/silverstripe-framework
src/Forms/TreeMultiselectField.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/TreeMultiselectField.php
BSD-3-Clause
public function performReadonlyTransformation() { $copy = $this->castedCopy(TreeMultiselectField_Readonly::class); $copy->setKeyField($this->getKeyField()); $copy->setLabelField($this->getLabelField()); $copy->setSourceObject($this->getSourceObject()); $copy->setTitleField($this->getTitleField()); return $copy; }
Changes this field to the readonly field.
performReadonlyTransformation
php
silverstripe/silverstripe-framework
src/Forms/TreeMultiselectField.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/TreeMultiselectField.php
BSD-3-Clause
public function getSchemaDataDefaults() { $data = parent::getSchemaDataDefaults(); $data['data']['rows'] = $this->getRows(); $data['data']['columns'] = $this->getColumns(); $data['data']['maxlength'] = $this->getMaxLength(); return $data; }
Set textarea specific schema data
getSchemaDataDefaults
php
silverstripe/silverstripe-framework
src/Forms/TextareaField.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/TextareaField.php
BSD-3-Clause
public function setRows($rows) { $this->rows = $rows; return $this; }
Set the number of rows in the textarea @param int $rows @return $this
setRows
php
silverstripe/silverstripe-framework
src/Forms/TextareaField.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/TextareaField.php
BSD-3-Clause
public function setColumns($cols) { $this->cols = $cols; return $this; }
Set the number of columns in the textarea @param int $cols @return $this
setColumns
php
silverstripe/silverstripe-framework
src/Forms/TextareaField.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/TextareaField.php
BSD-3-Clause
public function getColumns() { return $this->cols; }
Gets the number of columns in this textarea @return int
getColumns
php
silverstripe/silverstripe-framework
src/Forms/TextareaField.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/TextareaField.php
BSD-3-Clause
public function ValueEntities() { Deprecation::noticeWithNoReplacment('5.4.0', 'Will be replaced by getFormattedValueEntities()'); return htmlentities($this->Value() ?? '', ENT_COMPAT, 'UTF-8'); }
Return value with all values encoded in html entities @return string Raw HTML @deprecated 5.4.0 Use getFormattedValueEntities() instead
ValueEntities
php
silverstripe/silverstripe-framework
src/Forms/TextareaField.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/TextareaField.php
BSD-3-Clause
public function hasMethod($method) { return true; }
Ensure that all potential method calls get passed to __call(), therefore to dataFieldByName @param string $method @return bool
hasMethod
php
silverstripe/silverstripe-framework
src/Forms/Form_FieldMap.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/Form_FieldMap.php
BSD-3-Clause
public function getCurrencyField() { return $this->fieldCurrency; }
Gets field for the currency selector @return FormField
getCurrencyField
php
silverstripe/silverstripe-framework
src/Forms/MoneyField.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/MoneyField.php
BSD-3-Clause
public function getAmountField() { return $this->fieldAmount; }
Gets field for the amount input @return NumericField
getAmountField
php
silverstripe/silverstripe-framework
src/Forms/MoneyField.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/MoneyField.php
BSD-3-Clause
protected function getDBMoney() { return DBMoney::create_field('Money', [ 'Currency' => $this->fieldCurrency->dataValue(), 'Amount' => $this->fieldAmount->dataValue() ]) ->setLocale($this->getLocale()); }
Get value as DBMoney object useful for formatting the number @return DBMoney
getDBMoney
php
silverstripe/silverstripe-framework
src/Forms/MoneyField.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/MoneyField.php
BSD-3-Clause
public function saveInto(DataObjectInterface $dataObject) { $fieldName = $this->getName(); if ($dataObject->hasMethod("set$fieldName")) { $dataObject->$fieldName = $this->getDBMoney(); } else { $currencyField = "{$fieldName}Currency"; $amountField = "{$fieldName}Amount"; $dataObject->$currencyField = $this->fieldCurrency->dataValue(); $dataObject->$amountField = $this->fieldAmount->dataValue(); } }
30/06/2009 - Enhancement: SaveInto checks if set-methods are available and use them instead of setting the values in the money class directly. saveInto initiates a new Money class object to pass through the values to the setter method. (see @link MoneyFieldTest_CustomSetter_Object for more information) @param DataObjectInterface|Object $dataObject
saveInto
php
silverstripe/silverstripe-framework
src/Forms/MoneyField.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/MoneyField.php
BSD-3-Clause
public function setLocale($locale) { $this->fieldAmount->setLocale($locale); return $this; }
Assign locale to format this currency in @param string $locale @return $this
setLocale
php
silverstripe/silverstripe-framework
src/Forms/MoneyField.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/MoneyField.php
BSD-3-Clause
public function getLocale() { return $this->fieldAmount->getLocale(); }
Get locale to format this currency in. Defaults to current locale. @return string
getLocale
php
silverstripe/silverstripe-framework
src/Forms/MoneyField.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/MoneyField.php
BSD-3-Clause
public function getSchemaStateDefaults() { $state = parent::getSchemaStateDefaults(); $state['data']['title'] = $this->Title(); return $state; }
Header fields support dynamic titles via schema state @return array
getSchemaStateDefaults
php
silverstripe/silverstripe-framework
src/Forms/HeaderField.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/HeaderField.php
BSD-3-Clause
public function getSchemaDataDefaults() { $data = parent::getSchemaDataDefaults(); $data['data']['headingLevel'] = $this->headingLevel; return $data; }
Header fields heading level to be set @return array
getSchemaDataDefaults
php
silverstripe/silverstripe-framework
src/Forms/HeaderField.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/HeaderField.php
BSD-3-Clause
public function getTimeFormat() { if ($this->getHTML5()) { // Browsers expect ISO 8601 times, localisation is handled on the client $this->setTimeFormat(DBTime::ISO_TIME); } if ($this->timeFormat) { return $this->timeFormat; } // Get from locale return $this->getFrontendFormatter()->getPattern(); }
Get time format in CLDR standard format This can be set explicitly. If not, this will be generated from the current locale with the current time length. @see https://unicode-org.github.io/icu/userguide/format_parse/datetime/#date-field-symbol-table
getTimeFormat
php
silverstripe/silverstripe-framework
src/Forms/TimeField.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/TimeField.php
BSD-3-Clause
public function setTimeFormat($format) { $this->timeFormat = $format; return $this; }
Set time format in CLDR standard format. Only applicable with {@link setHTML5(false)}. @see https://unicode-org.github.io/icu/userguide/format_parse/datetime/#date-field-symbol-table @param string $format @return $this
setTimeFormat
php
silverstripe/silverstripe-framework
src/Forms/TimeField.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/TimeField.php
BSD-3-Clause
public function getTimeLength() { if ($this->timeLength) { return $this->timeLength; } return IntlDateFormatter::MEDIUM; }
Get length of the time format to use. One of: - IntlDateFormatter::SHORT E.g. '6:31 PM' - IntlDateFormatter::MEDIUM E.g. '6:30:48 PM' - IntlDateFormatter::LONG E.g. '6:32:09 PM NZDT' - IntlDateFormatter::FULL E.g. '6:32:24 PM New Zealand Daylight Time' @see http://php.net/manual/en/class.intldateformatter.php#intl.intldateformatter-constants @return int
getTimeLength
php
silverstripe/silverstripe-framework
src/Forms/TimeField.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/TimeField.php
BSD-3-Clause
public function setTimeLength($length) { $this->timeLength = $length; return $this; }
Get length of the time format to use. Only applicable with {@link setHTML5(false)}. @see http://php.net/manual/en/class.intldateformatter.php#intl.intldateformatter-constants @param int $length @return $this
setTimeLength
php
silverstripe/silverstripe-framework
src/Forms/TimeField.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/TimeField.php
BSD-3-Clause
protected function getInternalFormatter() { $formatter = IntlDateFormatter::create( i18n::config()->uninherited('default_locale'), IntlDateFormatter::NONE, IntlDateFormatter::MEDIUM, date_default_timezone_get() // Default to server timezone ); $formatter->setLenient(false); // Note we omit timezone from this format, and we assume server TZ always. $formatter->setPattern(DBTime::ISO_TIME); return $formatter; }
Get a time formatter for the ISO 8601 format @return IntlDateFormatter
getInternalFormatter
php
silverstripe/silverstripe-framework
src/Forms/TimeField.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/TimeField.php
BSD-3-Clause
public function setSubmittedValue($value, $data = null) { // Save raw value for later validation $this->rawValue = $value; // Parse from submitted value $this->value = $this->frontendToInternal($value); return $this; }
Assign value posted from form submission @param mixed $value @param mixed $data @return $this
setSubmittedValue
php
silverstripe/silverstripe-framework
src/Forms/TimeField.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/TimeField.php
BSD-3-Clause
public function setValue($value, $data = null) { // Save raw value for later validation $this->rawValue = $value; // Null case if (!$value) { $this->value = null; return $this; } // Re-run through formatter to tidy up (e.g. remove date component) $this->value = $this->tidyInternal($value); return $this; }
Set time assigned from database value @param mixed $value @param mixed $data @return $this
setValue
php
silverstripe/silverstripe-framework
src/Forms/TimeField.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/TimeField.php
BSD-3-Clause
public function getMidnight() { $formatter = $this->getFrontendFormatter(); $timestamp = $this->withTimezone($this->getTimezone(), function () { return strtotime('midnight'); }); return $formatter->format($timestamp); }
Show midnight in current format (adjusts for timezone) @return string
getMidnight
php
silverstripe/silverstripe-framework
src/Forms/TimeField.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/TimeField.php
BSD-3-Clause
public function setLocale($locale) { $this->locale = $locale; return $this; }
Determines the presented/processed format based on locale defaults, instead of explicitly setting {@link setTimeFormat()}. Only applicable with {@link setHTML5(false)}. @param string $locale @return $this
setLocale
php
silverstripe/silverstripe-framework
src/Forms/TimeField.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/TimeField.php
BSD-3-Clause
public function performReadonlyTransformation() { $result = $this->castedCopy(TimeField_Readonly::class); $result ->setValue(false) ->setHTML5($this->html5) ->setTimeFormat($this->timeFormat) ->setTimezone($this->getTimezone()) ->setLocale($this->locale) ->setTimeLength($this->timeLength) ->setValue($this->value); return $result; }
Creates a new readonly field specified below @return TimeField_Readonly
performReadonlyTransformation
php
silverstripe/silverstripe-framework
src/Forms/TimeField.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/TimeField.php
BSD-3-Clause
protected function frontendToInternal($time) { if (!$time) { return null; } $fromFormatter = $this->getFrontendFormatter(); $toFormatter = $this->getInternalFormatter(); $timestamp = $fromFormatter->parse($time); // Try to parse time without seconds, since that's a valid HTML5 submission format // See https://html.spec.whatwg.org/multipage/infrastructure.html#times if ($timestamp === false && $this->getHTML5()) { $fromFormatter->setPattern(str_replace(':ss', '', DBTime::ISO_TIME ?? '')); $timestamp = $fromFormatter->parse($time); } // If timestamp still can't be detected, we've got an invalid time if ($timestamp === false) { return null; } return $toFormatter->format($timestamp); }
Convert frontend time to the internal representation (ISO 8601). The frontend time is also in ISO 8601 when $html5=true. @param string $time @return string The formatted time, or null if not a valid time
frontendToInternal
php
silverstripe/silverstripe-framework
src/Forms/TimeField.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/TimeField.php
BSD-3-Clause
protected function internalToFrontend($time) { $time = $this->tidyInternal($time); if (!$time) { return null; } $fromFormatter = $this->getInternalFormatter(); $toFormatter = $this->getFrontendFormatter(); $timestamp = $fromFormatter->parse($time); if ($timestamp === false) { return null; } return $toFormatter->format($timestamp); }
Convert the internal time representation (ISO 8601) to a format used by the frontend, as defined by {@link $timeFormat}. With $html5=true, the frontend time will also be in ISO 8601. @param string $time @return string
internalToFrontend
php
silverstripe/silverstripe-framework
src/Forms/TimeField.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/TimeField.php
BSD-3-Clause
protected function tidyInternal($time) { if (!$time) { return null; } // Re-run through formatter to tidy up (e.g. remove date component) $formatter = $this->getInternalFormatter(); $timestamp = $formatter->parse($time); if ($timestamp === false) { // Fallback to strtotime $timestamp = strtotime($time ?? '', DBDatetime::now()->getTimestamp()); if ($timestamp === false) { return null; } } return $formatter->format($timestamp); }
Tidy up the internal time representation (ISO 8601), and fall back to strtotime() if there's parsing errors. @param string $time Time in ISO 8601 or approximate form @return string ISO 8601 time, or null if not valid
tidyInternal
php
silverstripe/silverstripe-framework
src/Forms/TimeField.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/TimeField.php
BSD-3-Clause
protected function withTimezone($timezone, $callback) { $currentTimezone = date_default_timezone_get(); try { if ($timezone) { date_default_timezone_set($timezone ?? ''); } return $callback(); } finally { // Restore timezone if ($timezone) { date_default_timezone_set($currentTimezone); } } }
Run a callback within a specific timezone @param string $timezone @param callable $callback
withTimezone
php
silverstripe/silverstripe-framework
src/Forms/TimeField.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/TimeField.php
BSD-3-Clause
public function ValueEntities() { return htmlentities($this->Value() ?? '', ENT_COMPAT, 'UTF-8'); }
Return value with all values encoded in html entities @return string Raw HTML
ValueEntities
php
silverstripe/silverstripe-framework
src/Forms/HTMLReadonlyField.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/HTMLReadonlyField.php
BSD-3-Clause
protected function getFormFields(RequestHandler $controller = null, $name, $context = []) { // Fall back to standard "getCMSFields" which itself uses the FormScaffolder as a fallback $fields = $context['Record']->getCMSFields(); $this->invokeWithExtensions('updateFormFields', $fields, $controller, $name, $context); return $fields; }
Build field list for this form @param RequestHandler $controller @param string $name @param array $context @return FieldList
getFormFields
php
silverstripe/silverstripe-framework
src/Forms/DefaultFormFactory.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/DefaultFormFactory.php
BSD-3-Clause
protected function getFormActions(RequestHandler $controller = null, $name, $context = []) { $actions = $context['Record']->getCMSActions(); $this->invokeWithExtensions('updateFormActions', $actions, $controller, $name, $context); return $actions; }
Build list of actions for this form @param RequestHandler $controller @param string $name @param array $context @return FieldList
getFormActions
php
silverstripe/silverstripe-framework
src/Forms/DefaultFormFactory.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/DefaultFormFactory.php
BSD-3-Clause
public function getRequiredContext() { return ['Record']; }
Return list of mandatory context keys @return mixed
getRequiredContext
php
silverstripe/silverstripe-framework
src/Forms/DefaultFormFactory.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/DefaultFormFactory.php
BSD-3-Clause
public static function name_to_label($fieldName) { // Handle dot delimiters if (strpos($fieldName ?? '', '.') !== false) { $parts = explode('.', $fieldName ?? ''); // Ensure that any letter following a dot is uppercased, so that the regex below can break it up // into words $label = implode(array_map('ucfirst', $parts ?? [])); } else { $label = $fieldName; } // Replace any capital letter that is followed by a lowercase letter with a space, the lowercased // version of itself then the remaining lowercase letters. $labelWithSpaces = preg_replace_callback('/([A-Z])([a-z]+)/', function ($matches) { return ' ' . strtolower($matches[1] ?? '') . $matches[2]; }, $label ?? ''); // Add a space before any capital letter block that is at the end of the string $labelWithSpaces = preg_replace('/([a-z])([A-Z]+)$/', '$1 $2', $labelWithSpaces ?? ''); // The first letter should be uppercase return ucfirst(trim($labelWithSpaces ?? '')); }
Takes a field name and converts camelcase to spaced words. Also resolves combined field names with dot syntax to spaced words. Examples: - 'TotalAmount' will return 'Total amount' - 'Organisation.ZipCode' will return 'Organisation zip code' @param string $fieldName @return string
name_to_label
php
silverstripe/silverstripe-framework
src/Forms/FormField.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/FormField.php
BSD-3-Clause
public function ID() { return $this->getTemplateHelper()->generateFieldID($this); }
Returns the HTML ID of the field. The ID is generated as FormName_FieldName. All Field functions should ensure that this ID is included in the field. @return string
ID
php
silverstripe/silverstripe-framework
src/Forms/FormField.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/FormField.php
BSD-3-Clause
public function HolderID() { return $this->getTemplateHelper()->generateFieldHolderID($this); }
Returns the HTML ID for the form field holder element. @return string
HolderID
php
silverstripe/silverstripe-framework
src/Forms/FormField.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/FormField.php
BSD-3-Clause
public function getTemplateHelper() { if ($this->form) { return $this->form->getTemplateHelper(); } return FormTemplateHelper::singleton(); }
Returns the current {@link FormTemplateHelper} on either the parent Form or the global helper set through the {@link Injector} layout. To customize a single {@link FormField}, use {@link setTemplate} and provide a custom template name. @return FormTemplateHelper
getTemplateHelper
php
silverstripe/silverstripe-framework
src/Forms/FormField.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/FormField.php
BSD-3-Clause
public function saveInto(DataObjectInterface $record) { $component = $record; $fieldName = $this->name; // Allow for dot syntax if (($pos = strrpos($this->name ?? '', '.')) !== false) { $relation = substr($this->name ?? '', 0, $pos); $fieldName = substr($this->name ?? '', $pos + 1); $component = $record->relObject($relation); } if ($fieldName && $component) { $component->setCastedField($fieldName, $this->dataValue()); } else { $record->setCastedField($this->name, $this->dataValue()); } }
Method to save this form field into the given record. By default, makes use of $this->dataValue() @param ViewableData|DataObjectInterface $record Record to save data into
saveInto
php
silverstripe/silverstripe-framework
src/Forms/FormField.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/FormField.php
BSD-3-Clause
public function dataValue() { return $this->value; }
Returns the field value suitable for insertion into the data object. @see Formfield::setValue() @return mixed
dataValue
php
silverstripe/silverstripe-framework
src/Forms/FormField.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/FormField.php
BSD-3-Clause
public function Title() { return $this->title; }
Returns the field label - used by templates. @return string
Title
php
silverstripe/silverstripe-framework
src/Forms/FormField.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/FormField.php
BSD-3-Clause
public function setTitle($title) { $this->title = $title; return $this; }
Set the title of this formfield. Note: This expects escaped HTML. @param string $title Escaped HTML for title @return $this
setTitle
php
silverstripe/silverstripe-framework
src/Forms/FormField.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/FormField.php
BSD-3-Clause
public function RightTitle() { return $this->rightTitle; }
Gets the contextual label than can be used for additional field description. Can be shown to the right or under the field in question. @return string Contextual label text
RightTitle
php
silverstripe/silverstripe-framework
src/Forms/FormField.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/FormField.php
BSD-3-Clause
public function setRightTitle($rightTitle) { $this->rightTitle = $rightTitle; return $this; }
Sets the right title for this formfield @param string|DBField $rightTitle Plain text string, or a DBField with appropriately escaped HTML @return $this
setRightTitle
php
silverstripe/silverstripe-framework
src/Forms/FormField.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/FormField.php
BSD-3-Clause
public function extraClass() { $classes = []; $classes[] = $this->Type(); if ($this->extraClasses) { $classes = array_merge( $classes, array_values($this->extraClasses ?? []) ); } if (!$this->Title()) { $classes[] = 'form-group--no-label'; } // Allow custom styling of any element in the container based on validation errors, // e.g. red borders on input tags. // // CSS class needs to be different from the one rendered through {@link FieldHolder()}. if ($this->getMessage()) { $classes[] = 'holder-' . $this->getMessageType(); } return implode(' ', $classes); }
Compiles all CSS-classes. Optionally includes a "form-group--no-label" class if no title was set on the FormField. Uses {@link Message()} and {@link MessageType()} to add validation error classes which can be used to style the contained tags. @return string
extraClass
php
silverstripe/silverstripe-framework
src/Forms/FormField.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/FormField.php
BSD-3-Clause
public function addExtraClass($class) { $classes = preg_split('/\s+/', $class ?? ''); foreach ($classes as $class) { $this->extraClasses[$class] = $class; } return $this; }
Add one or more CSS-classes to the FormField container. Multiple class names should be space delimited. @param string $class @return $this
addExtraClass
php
silverstripe/silverstripe-framework
src/Forms/FormField.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/FormField.php
BSD-3-Clause
public function attrTitle() { return Convert::raw2att($this->title); }
Returns a version of a title suitable for insertion into an HTML attribute. @return string
attrTitle
php
silverstripe/silverstripe-framework
src/Forms/FormField.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/FormField.php
BSD-3-Clause
public function setSubmittedValue($value, $data = null) { return $this->setValue($value, $data); }
Set value assigned from a submitted form postback. Can be overridden to handle custom behaviour for user-localised data formats. @param mixed $value @param array|ViewableData $data @return $this
setSubmittedValue
php
silverstripe/silverstripe-framework
src/Forms/FormField.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/FormField.php
BSD-3-Clause
public function setForm($form) { $this->form = $form; return $this; }
Set the container form. This is called automatically when fields are added to forms. @param Form $form @return $this
setForm
php
silverstripe/silverstripe-framework
src/Forms/FormField.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/FormField.php
BSD-3-Clause
public function setCustomValidationMessage($customValidationMessage) { $this->customValidationMessage = $customValidationMessage; return $this; }
Set the custom error message to show instead of the default format. Different from setError() as that appends it to the standard error messaging. @param string $customValidationMessage @return $this
setCustomValidationMessage
php
silverstripe/silverstripe-framework
src/Forms/FormField.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/FormField.php
BSD-3-Clause
public function getCustomValidationMessage() { return $this->customValidationMessage; }
Get the custom error message for this form field. If a custom message has not been defined then just return blank. The default error is defined on {@link Validator}. @return string
getCustomValidationMessage
php
silverstripe/silverstripe-framework
src/Forms/FormField.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/FormField.php
BSD-3-Clause
public function FieldHolder($properties = []) { $context = $this; $this->extend('onBeforeRenderHolder', $context, $properties); if (count($properties ?? [])) { $context = $context->customise($properties); } return $context->renderWith($context->getFieldHolderTemplates()); }
Returns a "field holder" for this field. Forms are constructed by concatenating a number of these field holders. The default field holder is a label and a form field inside a div. @see FieldHolder.ss @param array $properties @return DBHTMLText
FieldHolder
php
silverstripe/silverstripe-framework
src/Forms/FormField.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/FormField.php
BSD-3-Clause
public function SmallFieldHolder($properties = []) { $context = $this; if (count($properties ?? [])) { $context = $this->customise($properties); } return $context->renderWith($this->getSmallFieldHolderTemplates()); }
Returns a restricted field holder used within things like FieldGroups. @param array $properties @return string
SmallFieldHolder
php
silverstripe/silverstripe-framework
src/Forms/FormField.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/FormField.php
BSD-3-Clause
protected function _templates($customTemplate = null, $customTemplateSuffix = null) { $templates = SSViewer::get_templates_by_class(static::class, $customTemplateSuffix, __CLASS__); // Prefer any custom template if ($customTemplate) { // Prioritise direct template array_unshift($templates, $customTemplate); } return $templates; }
Generate an array of class name strings to use for rendering this form field into HTML. @param string $customTemplate @param string $customTemplateSuffix @return array
_templates
php
silverstripe/silverstripe-framework
src/Forms/FormField.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/FormField.php
BSD-3-Clause
public function isComposite() { return false; }
Returns true if this field is a composite field. To create composite field types, you should subclass {@link CompositeField}. @return bool
isComposite
php
silverstripe/silverstripe-framework
src/Forms/FormField.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/FormField.php
BSD-3-Clause
public function hasData() { return true; }
Returns true if this field has its own data. Some fields, such as titles and composite fields, don't actually have any data. It doesn't make sense for data-focused methods to look at them. By overloading hasData() to return false, you can prevent any data-focused methods from looking at it. @return bool
hasData
php
silverstripe/silverstripe-framework
src/Forms/FormField.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/FormField.php
BSD-3-Clause
public function setReadonly($readonly) { $this->readonly = $readonly; return $this; }
Sets a read-only flag on this FormField. Use performReadonlyTransformation() to transform this instance. Setting this to false has no effect on the field. @param bool $readonly @return $this
setReadonly
php
silverstripe/silverstripe-framework
src/Forms/FormField.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/FormField.php
BSD-3-Clause
public function setDisabled($disabled) { $this->disabled = $disabled; return $this; }
Sets a disabled flag on this FormField. Use performDisabledTransformation() to transform this instance. Setting this to false has no effect on the field. @param bool $disabled @return $this
setDisabled
php
silverstripe/silverstripe-framework
src/Forms/FormField.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/FormField.php
BSD-3-Clause
public function setAutofocus($autofocus) { $this->autofocus = $autofocus; return $this; }
Sets a autofocus flag on this FormField. @param bool $autofocus @return $this
setAutofocus
php
silverstripe/silverstripe-framework
src/Forms/FormField.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/FormField.php
BSD-3-Clause
public function performReadonlyTransformation() { $readonlyClassName = static::class . '_Readonly'; if (ClassInfo::exists($readonlyClassName)) { $clone = $this->castedCopy($readonlyClassName); } else { $clone = $this->castedCopy(ReadonlyField::class); } $clone->setReadonly(true); return $clone; }
Returns a read-only version of this field. @return FormField
performReadonlyTransformation
php
silverstripe/silverstripe-framework
src/Forms/FormField.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/FormField.php
BSD-3-Clause
public function performDisabledTransformation() { $disabledClassName = static::class . '_Disabled'; if (ClassInfo::exists($disabledClassName)) { $clone = $this->castedCopy($disabledClassName); } else { $clone = clone $this; } $clone->setDisabled(true); return $clone; }
Return a disabled version of this field. Tries to find a class of the class name of this field suffixed with "_Disabled", failing that, finds a method {@link setDisabled()}. @return FormField
performDisabledTransformation
php
silverstripe/silverstripe-framework
src/Forms/FormField.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/FormField.php
BSD-3-Clause
public function hasClass($class) { $classes = explode(' ', strtolower($this->extraClass() ?? '')); return in_array(strtolower(trim($class ?? '')), $classes ?? []); }
Returns whether the current field has the given class added @param string $class @return bool
hasClass
php
silverstripe/silverstripe-framework
src/Forms/FormField.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/FormField.php
BSD-3-Clause
public function Type() { $type = new ReflectionClass($this); return strtolower(preg_replace('/Field$/', '', $type->getShortName() ?? '') ?? ''); }
Returns the field type. The field type is the class name with the word Field dropped off the end, all lowercase. It's handy for assigning HTML classes. Doesn't signify the input type attribute. @see {@link getAttributes()}. @return string
Type
php
silverstripe/silverstripe-framework
src/Forms/FormField.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/FormField.php
BSD-3-Clause
public function validate($validator) { Deprecation::noticeWithNoReplacment( '5.4.0', 'This method will take zero arguments and return a ValidationResult' . ' object instead of a boolean in CMS 6.0.0' ); return $this->extendValidationResult(true, $validator); }
Abstract method each {@link FormField} subclass must implement, determines whether the field is valid or not based on the value. @param Validator $validator @return bool
validate
php
silverstripe/silverstripe-framework
src/Forms/FormField.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/FormField.php
BSD-3-Clause
public function forTemplate() { return $this->Field(); }
This function is used by the template processor. If you refer to a field as a $ variable, it will return the $Field value. @return string
forTemplate
php
silverstripe/silverstripe-framework
src/Forms/FormField.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/FormField.php
BSD-3-Clause
public function setContainerFieldList($containerFieldList) { $this->containerFieldList = $containerFieldList; return $this; }
Set the FieldList that contains this field. @param FieldList $containerFieldList @return $this
setContainerFieldList
php
silverstripe/silverstripe-framework
src/Forms/FormField.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/FormField.php
BSD-3-Clause
public function getContainerFieldList() { return $this->containerFieldList; }
Get the FieldList that contains this field. @return FieldList
getContainerFieldList
php
silverstripe/silverstripe-framework
src/Forms/FormField.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/FormField.php
BSD-3-Clause
public function canSubmitValue() { return $this->hasData() && !$this->isReadonly() && !$this->isDisabled(); }
Determine if the value of this formfield accepts front-end submitted values and is saveable. @return bool
canSubmitValue
php
silverstripe/silverstripe-framework
src/Forms/FormField.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/FormField.php
BSD-3-Clause
public function setSchemaComponent($componentType) { $this->schemaComponent = $componentType; return $this; }
Sets the component type the FormField will be rendered as on the front-end. @param string $componentType @return static
setSchemaComponent
php
silverstripe/silverstripe-framework
src/Forms/FormField.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/FormField.php
BSD-3-Clause
public function getSchemaComponent() { return $this->schemaComponent; }
Gets the type of front-end component the FormField will be rendered as. @return string
getSchemaComponent
php
silverstripe/silverstripe-framework
src/Forms/FormField.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/FormField.php
BSD-3-Clause
public function setSchemaData($schemaData = []) { $defaults = $this->getSchemaData(); $this->schemaData = array_merge($this->schemaData, array_intersect_key($schemaData ?? [], $defaults)); return $this; }
Sets the schema data used for rendering the field on the front-end. Merges the passed array with the current `$schemaData` or {@link getSchemaDataDefaults()}. Any passed keys that are not defined in {@link getSchemaDataDefaults()} are ignored. If you want to pass around ad hoc data use the `data` array e.g. pass `['data' => ['myCustomKey' => 'yolo']]`. @param array $schemaData - The data to be merged with $this->schemaData. @return static
setSchemaData
php
silverstripe/silverstripe-framework
src/Forms/FormField.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/FormField.php
BSD-3-Clause
public function getSchemaData() { $defaults = $this->getSchemaDataDefaults(); return array_replace_recursive($defaults ?? [], array_intersect_key($this->schemaData ?? [], $defaults)); }
Gets the schema data used to render the FormField on the front-end. @return array
getSchemaData
php
silverstripe/silverstripe-framework
src/Forms/FormField.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/FormField.php
BSD-3-Clause
public function getSchemaDataDefaults() { $data = [ 'name' => $this->getName(), 'id' => $this->ID(), 'type' => $this->getInputType(), 'schemaType' => $this->getSchemaDataType(), 'component' => $this->getSchemaComponent(), 'holderId' => $this->HolderID(), 'title' => $this->obj('Title')->getSchemaValue(), 'source' => null, 'extraClass' => $this->extraClass(), 'description' => $this->obj('Description')->getSchemaValue(), 'rightTitle' => $this->obj('RightTitle')->getSchemaValue(), 'leftTitle' => $this->obj('LeftTitle')->getSchemaValue(), 'readOnly' => $this->isReadonly(), 'disabled' => $this->isDisabled(), 'customValidationMessage' => $this->getCustomValidationMessage(), 'validation' => $this->getSchemaValidation(), 'attributes' => [], 'autoFocus' => $this->isAutofocus(), 'data' => [], ]; $titleTip = $this->getTitleTip(); if ($titleTip instanceof Tip) { $data['titleTip'] = $titleTip->getTipSchema(); } return $data; }
Gets the defaults for $schemaData. The keys defined here are immutable, meaning undefined keys passed to {@link setSchemaData()} are ignored. Instead the `data` array should be used to pass around ad hoc data. @return array
getSchemaDataDefaults
php
silverstripe/silverstripe-framework
src/Forms/FormField.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/FormField.php
BSD-3-Clause
public function setSchemaState($schemaState = []) { $defaults = $this->getSchemaState(); $this->schemaState = array_merge($this->schemaState, array_intersect_key($schemaState ?? [], $defaults)); return $this; }
Sets the schema data used for rendering the field on the front-end. Merges the passed array with the current `$schemaState` or {@link getSchemaStateDefaults()}. Any passed keys that are not defined in {@link getSchemaStateDefaults()} are ignored. If you want to pass around ad hoc data use the `data` array e.g. pass `['data' => ['myCustomKey' => 'yolo']]`. @param array $schemaState The data to be merged with $this->schemaData. @return static
setSchemaState
php
silverstripe/silverstripe-framework
src/Forms/FormField.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/FormField.php
BSD-3-Clause
public function getSchemaState() { $defaults = $this->getSchemaStateDefaults(); return array_merge($defaults, array_intersect_key($this->schemaState ?? [], $defaults)); }
Gets the schema state used to render the FormField on the front-end. @return array
getSchemaState
php
silverstripe/silverstripe-framework
src/Forms/FormField.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/FormField.php
BSD-3-Clause
public function getSchemaStateDefaults() { $state = [ 'name' => $this->getName(), 'id' => $this->ID(), 'value' => $this->Value(), 'message' => $this->getSchemaMessage(), 'data' => [], ]; return $state; }
Gets the defaults for $schemaState. The keys defined here are immutable, meaning undefined keys passed to {@link setSchemaState()} are ignored. Instead the `data` array should be used to pass around ad hoc data. Includes validation data if the field is associated to a {@link Form}, and {@link Form->validate()} has been called. @return array
getSchemaStateDefaults
php
silverstripe/silverstripe-framework
src/Forms/FormField.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/FormField.php
BSD-3-Clause
public function getSchemaValidation() { $validationList = []; if ($this->Required()) { $validationList['required'] = true; } $this->extend('updateSchemaValidation', $validationList); return $validationList; }
Return list of validation rules. Each rule is a key value pair. The key is the rule name. The value is any information the frontend validation handler can understand, or just `true` to enable. @return array
getSchemaValidation
php
silverstripe/silverstripe-framework
src/Forms/FormField.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/FormField.php
BSD-3-Clause
public function getDateLength() { if ($this->dateLength) { return $this->dateLength; } return IntlDateFormatter::MEDIUM; }
Get length of the date format to use. One of: - IntlDateFormatter::SHORT - IntlDateFormatter::MEDIUM - IntlDateFormatter::LONG - IntlDateFormatter::FULL @see http://php.net/manual/en/class.intldateformatter.php#intl.intldateformatter-constants @return int
getDateLength
php
silverstripe/silverstripe-framework
src/Forms/DateField.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/DateField.php
BSD-3-Clause
public function setDateLength($length) { $this->dateLength = $length; return $this; }
Get length of the date format to use. Only applicable with {@link setHTML5(false)}. @see http://php.net/manual/en/class.intldateformatter.php#intl.intldateformatter-constants @param int $length @return $this
setDateLength
php
silverstripe/silverstripe-framework
src/Forms/DateField.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/DateField.php
BSD-3-Clause
public function getDateFormat() { // Browsers expect ISO 8601 dates, localisation is handled on the client if ($this->getHTML5()) { return DBDate::ISO_DATE; } if ($this->dateFormat) { return $this->dateFormat; } // Get from locale return $this->getFrontendFormatter()->getPattern(); }
Get date format in CLDR standard format This can be set explicitly. If not, this will be generated from the current locale with the current date length. @see https://unicode-org.github.io/icu/userguide/format_parse/datetime/#date-field-symbol-table
getDateFormat
php
silverstripe/silverstripe-framework
src/Forms/DateField.php
https://github.com/silverstripe/silverstripe-framework/blob/master/src/Forms/DateField.php
BSD-3-Clause