Consistently use 'value' for FormField schemas

LiteralField (data.content) was inconsistent with HTMLReadonlyField (value),
which made the frontend components harder to handle.

See https://github.com/silverstripe/silverstripe-framework/pull/6172#discussion_r83561757 for contex
This commit is contained in:
Ingo Schommer 2016-10-20 21:04:41 +13:00
parent 84c0df3db0
commit 54a4cef863
3 changed files with 7 additions and 13 deletions

View File

@ -122,8 +122,7 @@ class LiteralField extends DatalessField {
*/ */
public function getSchemaStateDefaults() { public function getSchemaStateDefaults() {
$state = parent::getSchemaStateDefaults(); $state = parent::getSchemaStateDefaults();
$state['value'] = $this->FieldHolder();
$state['data']['content'] = $this->FieldHolder();
return $state; return $state;
} }

View File

@ -62,10 +62,10 @@ class ReadonlyField extends FormField {
} }
public function getSchemaStateDefaults() { public function getSchemaStateDefaults() {
$values = parent::getSchemaStateDefaults(); $state = parent::getSchemaStateDefaults();
// Suppress `<i>('none')</i>` from appearing in react as a literal $state['value'] = $this->dataValue();
$values['value'] = $this->dataValue();
return $values; return $state;
} }

View File

@ -8,7 +8,7 @@ class LiteralField extends SilverStripeComponent {
* @returns {object} innerHtml * @returns {object} innerHtml
*/ */
getContent() { getContent() {
return { __html: this.props.data.content }; return { __html: this.props.value };
} }
/** /**
@ -41,12 +41,7 @@ LiteralField.propTypes = {
id: React.PropTypes.string, id: React.PropTypes.string,
name: React.PropTypes.string.isRequired, name: React.PropTypes.string.isRequired,
extraClass: React.PropTypes.string, extraClass: React.PropTypes.string,
data: React.PropTypes.oneOfType([ value: React.PropTypes.string,
React.PropTypes.array,
React.PropTypes.shape({
content: React.PropTypes.string.isRequired,
}),
]).isRequired,
}; };
LiteralField.defaultProps = { LiteralField.defaultProps = {