diff --git a/src/ReactFormField.php b/src/ReactFormField.php index 5114dc5..5220dc1 100644 --- a/src/ReactFormField.php +++ b/src/ReactFormField.php @@ -12,9 +12,9 @@ abstract class ReactFormField extends FormField implements ReactComponent { /** - * Whether an input taf shoulde be rendered when using the React component + * Whether an input tag should be rendered when using the React component * in an entwine form. If the React implementation of the field does not output - * an input tag (or someother HTML form field), this should be set to true. + * an input tag (or some other HTML form field), this should be set to true. * @var bool */ protected $renderInput = false; @@ -45,7 +45,7 @@ public function getProps(): array { return [ 'name' => $this->getName(), - 'value' => $this->Value(), + 'value' => $this->InputValue(), 'extraClass' => $this->extraClass(), 'id' => $this->ID(), 'disabled' => $this->isDisabled(), @@ -69,4 +69,22 @@ public function HiddenID(): string { return $this->ID() . '_HiddenValueField'; } + + /** + * Convert the value to what will be rendered in thi input on the front end + */ + public function InputValue(): string + { + return $this->Value(); + } + + + public function getSchemaData() + { + $schema = parent::getSchemaData(); + + $schema = array_merge($schema, $this->getProps()); + + return $schema; + } } diff --git a/templates/MaximeRainville/SilverstripeReact/ReactFormField.ss b/templates/MaximeRainville/SilverstripeReact/ReactFormField.ss index 4c93330..52e889f 100644 --- a/templates/MaximeRainville/SilverstripeReact/ReactFormField.ss +++ b/templates/MaximeRainville/SilverstripeReact/ReactFormField.ss @@ -1,5 +1,5 @@ <% if $RenderInput %> - + <% end_if %>