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() {
|
public function getSchemaStateDefaults() {
|
||||||
$state = parent::getSchemaStateDefaults();
|
$state = parent::getSchemaStateDefaults();
|
||||||
|
$state['value'] = $this->FieldHolder();
|
||||||
$state['data']['content'] = $this->FieldHolder();
|
|
||||||
|
|
||||||
return $state;
|
return $state;
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -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 = {
|
||||||
|
Loading…
Reference in New Issue
Block a user