Move FormIntl/FormNested switch from FromComponentInner to FormComponent

This commit is contained in:
SachaG 2018-06-28 18:36:57 +02:00
parent d0832c3c20
commit a01ca2ab6e
2 changed files with 17 additions and 20 deletions

View file

@ -293,6 +293,11 @@ class FormComponent extends Component {
};
render() {
if (this.props.intlInput) {
return <Components.FormIntl {...this.props} />;
} else if (this.props.nestedInput){
return <Components.FormNested {...this.props} />;
}
return (
<Components.FormComponentInner
{...this.props}

View file

@ -51,8 +51,6 @@ class FormComponentInner extends PureComponent {
showCharsRemaining,
charsRemaining,
renderComponent,
intlInput,
nestedInput,
} = this.props;
const hasErrors = errors && errors.length;
@ -69,24 +67,18 @@ class FormComponentInner extends PureComponent {
const FormInput = this.props.formInput;
if (intlInput) {
return <Components.FormIntl {...properties} />;
} else if (nestedInput){
return <Components.FormNested {...properties} />;
} else {
return (
<div className={inputClass}>
{instantiateComponent(beforeComponent, properties)}
<FormInput {...properties}/>
{hasErrors ? <Components.FieldErrors errors={errors} /> : null}
{this.renderClear()}
{showCharsRemaining && (
<div className={classNames('form-control-limit', { danger: charsRemaining < 10 })}>{charsRemaining}</div>
)}
{instantiateComponent(afterComponent, properties)}
</div>
);
}
return (
<div className={inputClass}>
{instantiateComponent(beforeComponent, properties)}
<FormInput {...properties}/>
{hasErrors ? <Components.FieldErrors errors={errors} /> : null}
{this.renderClear()}
{showCharsRemaining && (
<div className={classNames('form-control-limit', { danger: charsRemaining < 10 })}>{charsRemaining}</div>
)}
{instantiateComponent(afterComponent, properties)}
</div>
);
}
}