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() {
$state = parent::getSchemaStateDefaults();
$state['data']['content'] = $this->FieldHolder();
$state['value'] = $this->FieldHolder();
return $state;
}

View File

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

View File

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