Hi,
I can't find tutorial for definition own submit value via schema object.
There is only way via the Form component's children: https://github.com/mozilla-services/react-jsonschema-form#form-action-buttons but I want to define all items, titles via one object for easy translation in future.
Is there another way?
Ok, now I see that isn't:
https://github.com/mozilla-services/react-jsonschema-form/blob/master/src/components/Form.js#L249-L256
I can send PR, can you please tell me how should I detect submit widget in schema to Form.js?
Hi @landsman ,
You can provide as children a hidden submit button and the button that you want to translate.
Whenever you click the visible button , make it trigger the submit action of the hidden button.
<Form
className={formClassNames}
formContext={formContext}
formData={this.props.formData}
onSubmit={this.handleSubmit}
transformErrors={transformErrors}
uiSchema={this.props.uiSchema}
>
<input
ref={button => {
this.submitButton = button;
}}
className="hidden"
type="submit"
value="Submit"
/>
<Button
onClick={this.handleVisibleSubmitButton}
type="button">
</Button>
</form>
The code above is just an example if you copy and paste it , it will not work, but it illustrate the idea.
@landsman You might prefer to subclass Form and override render(). I'm sure this isn't the only hard-coded string in this library so I think opening a PR might be more work than you intend. I guess I would consider a PR that adds ui:formButtons: {submit: "Envoyer"} or something.
@doncesarts, I also think, this feature doesn't needed.
We can directly pass children, the way we want. Why do we need this feature?
@james-gc this feature would just be useful as a convenience, if the user doesn't want to override the entire submit button but just wants to change the text.
Most helpful comment
@landsman You might prefer to subclass
Formand overriderender(). I'm sure this isn't the only hard-coded string in this library so I think opening a PR might be more work than you intend. I guess I would consider a PR that addsui:formButtons: {submit: "Envoyer"}or something.