mirror of
https://github.com/Kingsrook/qqq-frontend-material-dashboard.git
synced 2025-07-17 21:00:45 +00:00
QQQ-21: fixed isRequired being double checked
This commit is contained in:
@ -25,6 +25,7 @@
|
|||||||
"no-shadow": "off",
|
"no-shadow": "off",
|
||||||
"no-unused-vars": "off",
|
"no-unused-vars": "off",
|
||||||
"spaced-comment": "off",
|
"spaced-comment": "off",
|
||||||
|
"object-shorthand": "off",
|
||||||
"react/jsx-props-no-spreading": "off",
|
"react/jsx-props-no-spreading": "off",
|
||||||
"react/react-in-jsx-scope": "off",
|
"react/react-in-jsx-scope": "off",
|
||||||
"import/extensions": [
|
"import/extensions": [
|
||||||
|
@ -70,7 +70,6 @@ function QDynamicForm(props: Props): JSX.Element {
|
|||||||
return (
|
return (
|
||||||
<Grid item xs={12} sm={6} key={fieldName}>
|
<Grid item xs={12} sm={6} key={fieldName}>
|
||||||
<FormField
|
<FormField
|
||||||
required={field.isRequired}
|
|
||||||
type={field.type}
|
type={field.type}
|
||||||
label={field.label}
|
label={field.label}
|
||||||
name={fieldName}
|
name={fieldName}
|
||||||
|
@ -19,8 +19,10 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// misc imports
|
||||||
import * as Yup from "yup";
|
import * as Yup from "yup";
|
||||||
|
|
||||||
|
// qqq imports
|
||||||
import { QFieldMetaData } from "@kingsrook/qqq-frontend-core/lib/model/metaData/QFieldMetaData";
|
import { QFieldMetaData } from "@kingsrook/qqq-frontend-core/lib/model/metaData/QFieldMetaData";
|
||||||
import { QFieldType } from "@kingsrook/qqq-frontend-core/lib/model/metaData/QFieldType";
|
import { QFieldType } from "@kingsrook/qqq-frontend-core/lib/model/metaData/QFieldType";
|
||||||
|
|
||||||
@ -55,9 +57,12 @@ class DynamicFormUtils {
|
|||||||
fieldType = "text";
|
fieldType = "text";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let label = field.label ? field.label : field.name;
|
||||||
|
label += field.isRequired ? " *" : "";
|
||||||
|
|
||||||
dynamicFormFields[field.name] = {
|
dynamicFormFields[field.name] = {
|
||||||
name: field.name,
|
name: field.name,
|
||||||
label: field.label ? field.label : field.name,
|
label: label,
|
||||||
isRequired: field.isRequired,
|
isRequired: field.isRequired,
|
||||||
type: fieldType,
|
type: fieldType,
|
||||||
// todo invalidMsg: "Zipcode is not valid (e.g. 70000).",
|
// todo invalidMsg: "Zipcode is not valid (e.g. 70000).",
|
||||||
|
@ -91,19 +91,16 @@ function ProcessRun(): JSX.Element {
|
|||||||
setActiveStep(activeStep);
|
setActiveStep(activeStep);
|
||||||
setFormId(activeStep.name);
|
setFormId(activeStep.name);
|
||||||
|
|
||||||
const { dynamicFormFields, formValidations } = DynamicFormUtils.getFormData(
|
|
||||||
activeStep.formFields
|
|
||||||
);
|
|
||||||
|
|
||||||
const formFields: any = {};
|
|
||||||
const initialValues: any = {};
|
const initialValues: any = {};
|
||||||
const validations: any = {};
|
|
||||||
|
|
||||||
activeStep.formFields.forEach((field) => {
|
activeStep.formFields.forEach((field) => {
|
||||||
// todo - not working - also, needs real value.
|
// todo - not working - also, needs real value.
|
||||||
initialValues[field.name] = "Hi";
|
initialValues[field.name] = "Hi";
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const { dynamicFormFields, formValidations } = DynamicFormUtils.getFormData(
|
||||||
|
activeStep.formFields
|
||||||
|
);
|
||||||
|
|
||||||
setFormFields(dynamicFormFields);
|
setFormFields(dynamicFormFields);
|
||||||
setInitialValues(initialValues);
|
setInitialValues(initialValues);
|
||||||
setValidations(Yup.object().shape(formValidations));
|
setValidations(Yup.object().shape(formValidations));
|
||||||
|
Reference in New Issue
Block a user