QQQ-21: fixed isRequired being double checked

This commit is contained in:
Tim Chamberlain
2022-07-07 15:15:13 -05:00
parent 22e35cdfb0
commit 8354f81eca
4 changed files with 11 additions and 9 deletions

View File

@ -25,6 +25,7 @@
"no-shadow": "off",
"no-unused-vars": "off",
"spaced-comment": "off",
"object-shorthand": "off",
"react/jsx-props-no-spreading": "off",
"react/react-in-jsx-scope": "off",
"import/extensions": [

View File

@ -70,7 +70,6 @@ function QDynamicForm(props: Props): JSX.Element {
return (
<Grid item xs={12} sm={6} key={fieldName}>
<FormField
required={field.isRequired}
type={field.type}
label={field.label}
name={fieldName}

View File

@ -19,8 +19,10 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
// misc imports
import * as Yup from "yup";
// qqq imports
import { QFieldMetaData } from "@kingsrook/qqq-frontend-core/lib/model/metaData/QFieldMetaData";
import { QFieldType } from "@kingsrook/qqq-frontend-core/lib/model/metaData/QFieldType";
@ -55,9 +57,12 @@ class DynamicFormUtils {
fieldType = "text";
}
let label = field.label ? field.label : field.name;
label += field.isRequired ? " *" : "";
dynamicFormFields[field.name] = {
name: field.name,
label: field.label ? field.label : field.name,
label: label,
isRequired: field.isRequired,
type: fieldType,
// todo invalidMsg: "Zipcode is not valid (e.g. 70000).",

View File

@ -91,19 +91,16 @@ function ProcessRun(): JSX.Element {
setActiveStep(activeStep);
setFormId(activeStep.name);
const { dynamicFormFields, formValidations } = DynamicFormUtils.getFormData(
activeStep.formFields
);
const formFields: any = {};
const initialValues: any = {};
const validations: any = {};
activeStep.formFields.forEach((field) => {
// todo - not working - also, needs real value.
initialValues[field.name] = "Hi";
});
const { dynamicFormFields, formValidations } = DynamicFormUtils.getFormData(
activeStep.formFields
);
setFormFields(dynamicFormFields);
setInitialValues(initialValues);
setValidations(Yup.object().shape(formValidations));