Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to convert form io language #124

Closed
vishaldenzil opened this issue Aug 16, 2018 · 1 comment
Closed

Unable to convert form io language #124

vishaldenzil opened this issue Aug 16, 2018 · 1 comment

Comments

@vishaldenzil
Copy link

Hi,

I am trying to change one language to another language using option field in the Form io with particular data. onclicking the button am trying to change hindi language to malayalam. But Formio component is not rendering

Problem : Unable to change the language.

Node version : v10.3.0
Npm : 6.1.0
Form io : 1.17.1

import * as axios from "axios";
import React, { Component } from "react";
import { Form } from "react-formio";
import { routes } from "../urls";

class MyForm extends Component {
  constructor(props) {
    super(props);
    this.state = {
      form: undefined,
      admin: true,
      opts: {
        readOnly: false,
        language: "fr",
        i18n: {
          en: {
            Email: "ईमेल",
            Number: "संख्या",
            Submit: "जमा करें"
          },
          fr: {
            Email: "ഇമെയിൽ",
            Number: "സംഖ്യ",
            Submit: "Submit"
          }
        }
      }
    };
    this.handleSubmitFunction = this.handleSubmitFunction.bind(this);
    this.convertLanguage = this.convertLanguage.bind(this);
  }

  componentDidMount() {
    let components = {
      components: [
        {
          unique: false,
          suffix: "",
          conditional: {
            show: "",
            when: null,
            eq: ""
          },
          hidden: false,
          clearOnHide: true,
          defaultValue: "",
          tableView: true,
          label: "Email",
          protected: false,
          placeholder: "",
          properties: {
            "": ""
          },
          kickbox: {
            enabled: false
          },
          type: "email",
          hideLabel: false,
          prefix: "",
          tags: ["admin"],
          input: true,
          persistent: true,
          inputType: "email",
          key: "email",
          labelPosition: "top"
        },
        {
          suffix: "",
          properties: {
            "": ""
          },
          hidden: false,
          lockKey: true,
          clearOnHide: true,
          defaultValue: "",
          validate: {
            step: "any",
            integer: "",
            multiple: "",
            required: false,
            max: "",
            min: "",
            custom: ""
          },
          tableView: true,
          label: "Number",
          protected: false,
          placeholder: "",
          conditional: {
            show: "",
            when: null,
            eq: ""
          },
          type: "number",
          hideLabel: false,
          prefix: "",
          tags: ["print", "admin"],
          input: true,
          persistent: true,
          inputType: "number",
          key: "number",
          labelPosition: "top"
        },
        {
          type: "button",
          label: "submit",
          action: "submit",
          theme: "primary"
        }
      ]
    };
    this.setState({ form: components });
  }

  convertLanguage(e) {
    var form = { ...this.state.form };
    form.language = "en";

    var opts = { ...this.state.opts };
    opts.language = "en";
    this.setState({ form });
  }

  render() {
      return (
        <div>
          <input
            type="choice"
            onChange={this.convertLanguage}
            name="language"
            value="fr"
          />
          <Form
            onSubmit={this.handleSubmitFunction}
            form={this.state.form}
            options={this.state.opts}
          />
        </div>
      );
  }
}
export default MyFrom;
@TanyaGashtold
Copy link
Contributor

I am closing the issue as it was created too long ago and there are no new comments here. I hope it was resolved. If not, please reopen it. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants