Antd <ConfigProvider /> Support?
vedovato opened this issue · comments
Creating forms with FormBuilder Component is a breeze but it seems to not take advantage of ant's ConfigProvider component props/settings. I'm using locale prop with and it translates every other every component but FormBuilder generated forms.
There are any workaround for this?
That's my Wrapper:
import ptBR from "antd/lib/locale/pt_BR";
const AdminWrapper = (props) => {
message.config({ maxCount: 1 });
return (
<ConfigProvider locale={ptBR}>
<NewChildren {...props} />
</ConfigProvider>
);
};
FormBuilder example:
<Form
form={form}
layout="vertical"
onFinish={handleFinish}
validateMessages={validateMessages}
>
<Tabs tabPosition="top">
<Tabs.TabPane tab="Usuario" key="1">
<FormBuilder form={form} meta={meta1} initialValues={...} />
</Tabs.TabPane>
<Tabs.TabPane tab="Filiacao" key="2">
<FormBuilder form={form} meta={meta2} initialValues={...} />
</Tabs.TabPane>
</Tabs>
</Form>
Validation Message object used as
prop:export default {
required: "Campo obrigatorio",
types: {
email: "E-mail invalido",
number: "Numero invalido"
}
};
Yes, it is hard code for required field validation message. You can set message
property on form field meta as a workaround or define your own rules rather than required
property.
antd-form-builder/src/FormBuilderField.js
Line 140 in 57a50a3
Thank you, @supnate