This commit is contained in:
elforjani13
2022-04-03 19:42:11 +02:00
parent dbf4666dfc
commit c49a240280
2 changed files with 38 additions and 6 deletions

View File

@@ -50,7 +50,7 @@ export default function ItemFormFormik({
// Handles the form submit.
const handleFormSubmit = (values, form) => {
const { setSubmitting, resetForm, setErrors } = form;
const formValues = { ...values };
const formValues = { ...values, type: values.type.toString() };
setSubmitting(true);
@@ -96,7 +96,7 @@ export default function ItemFormFormik({
validationSchema={isNewMode ? CreateItemFormSchema : EditItemFormSchema}
initialValues={initialValues}
onSubmit={handleFormSubmit}
>
>
<Form>
<div class={classNames(CLASSES.PAGE_FORM_BODY)}>
<ItemFormPrimarySection />

View File

@@ -7,7 +7,12 @@ import {
Radio,
Position,
} from '@blueprintjs/core';
import { FormattedMessage as T, FormattedHTMLMessage } from 'components';
import {
FormattedMessage as T,
FormattedHTMLMessage,
FCheckbox,
FFormGroup,
} from 'components';
import { ErrorMessage, FastField } from 'formik';
import {
CategoriesSelectList,
@@ -29,7 +34,7 @@ import { categoriesFieldShouldUpdate } from './utils';
export default function ItemFormPrimarySection() {
// Item form context.
const { isNewMode, item, itemsCategories } = useItemFormContext();
console.log(item.type, 'XXX');
const nameFieldRef = useRef(null);
useEffect(() => {
@@ -53,7 +58,34 @@ export default function ItemFormPrimarySection() {
return (
<div className={classNames(CLASSES.PAGE_FORM_HEADER_PRIMARY)}>
{/*----------- Item type ----------*/}
<FastField name={'type'}>
<FFormGroup
name={'type'}
label={<T id={'item_type'} />}
labelInfo={
<span>
<FieldRequiredHint />
<Hint
content={itemTypeHintContent}
position={Position.BOTTOM_LEFT}
/>
</span>
}
inline={true}
>
<FCheckbox
inline={true}
name="type"
label={<T id={'service'} />}
value="service"
/>
<FCheckbox
inline={true}
name="type"
label={<T id={'inventory'} />}
value="inventory"
/>
</FFormGroup>
{/* <FastField name={'type'}>
{({ form, field: { value }, meta: { touched, error } }) => (
<FormGroup
medium={true}
@@ -85,7 +117,7 @@ export default function ItemFormPrimarySection() {
</RadioGroup>
</FormGroup>
)}
</FastField>
</FastField> */}
<Row>
<Col xs={7}>