React-jsonschema-form: define submit title via schema object?

Created on 2 Dec 2018  路  5Comments  路  Source: rjsf-team/react-jsonschema-form

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?

enhancement good first issue help wanted

Most helpful comment

@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.

All 5 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

abhishekpdubey picture abhishekpdubey  路  3Comments

anttivikman picture anttivikman  路  3Comments

sstarrAtmeta picture sstarrAtmeta  路  3Comments

Eric24 picture Eric24  路  3Comments

mammad2c picture mammad2c  路  3Comments