mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
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:
parent
84c0df3db0
commit
54a4cef863
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
@ -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 = {
|
||||
|
Loading…
Reference in New Issue
Block a user