import { Formly, IValue, IField } from "solid-formly";
const form_name = "formly_alter";
const fields: IField[] = [
{
type: "input",
name: "firstname",
attributes: {
type: "text",
id: "firstname",
placeholder: "Tap your first name",
},
},
{
type: "input",
name: "password",
attributes: {
type: "password",
id: "password",
placeholder: "Tap your password",
},
},
];
const Form = () => {
const onSubmit = (data: IValue) => {
console.log(data);
};
return (
<Formly
form_name={form_name}
fields={fields}
onSubmit={onSubmit}
btnSubmit={{
text: "Send Text", // text updated
classes: ["btn-primary"], // classes updated
}}
btnReset={{
text: "Reset Text", // , // text updated
classes: ["outline", "btn-primary"], // classes updated
}}
/>
);
};
export default Form;
Advanced
You can easly get a form more reactive using hook preprocess.
Alter Form
Change textes / classes for buttons submit and reset