-
Notifications
You must be signed in to change notification settings - Fork 20
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
clear form #51
Comments
The |
when I trigger here is my enhance form const validationRules = {
substore_uuid: [[isNotEmpty, 'Sila buat pilihan stor']],
quantity: [
[isNotEmpty, 'Sila masukkan kuantiti'],
[isInteger, 'Sila nombor bulat sahaja'],
],
};
const DistributeForm = ({onSubmit}) => {
const initialState = {
substore_uuid: '',
quantity: '',
};
if (disabled) return null;
return (
<Form
initialState={initialState}
rules={validationRules}
validateSingle={false}
validateOnChange
onSubmit={onSubmit}
/>
);
}; and here is the actual form bind with revalidation const StockForm = ({
onSubmit: submitCb,
max,
disabled,
revalidation: {form, valid, errors = {}, onSubmit, updateValueAndValidate},
}) => (
<form
onSubmit={e => {
e.preventDefault();
onSubmit(() => (valid ? submitCb(form) : null));
}}>
<div className="card-body">
<div
className={`form-group required ${errorClass(errors.substore_uuid)}`}>
<span>Substor</span>
<CommonSubstore
name="substore_uuid"
onChange={updateValueAndValidate}
/>
<ErrorLabel err={errors.substore_uuid} />
</div>
<div className={`form-group required ${errorClass(errors.quantity)}`}>
<span>Kuantiti Agihan</span>
<input
name="quantity"
type="number"
className="form-control"
required
max={max}
onChange={updateValueAndValidate}
/>
</div>
{errors.quantity.map(err => <ErrorLabel key={err} err={err} />)}
</div>
<div className="card-footer">
<button disabled={!valid || disabled} className="btn btn-success">
Agih
</button>
</div>
</form>
); Right now I didn't clear the form yet but if I do, I'd do it in my enhance form |
I'll give you feedback later on today. |
@muhaimincs I'm trying to rebuild your example, to get it running, I'll need more information. |
How do I clear the form once form values submitted? FYI, I use stateless component as container to the form. Please advice
The text was updated successfully, but these errors were encountered: