Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

309
Views
Redux form with submit to create, edit and delete records (multiple submit)

I am experimenting with react. I am mostly backend so frontend gives me some obvious troubles. I tried some google solutions but not getting any success. Here is the problem. I have following form. enter image description here

This form allows you to Create or Edit Service. There is same callback method for Saving the changes.

 export const createOrUpdateService = (data, _, props) => {
  console.log('Create or Update invoked.');
  if (data.id) {
    props.dispatch(actions.updateService(data.id, data));
  }
  else {
    props.dispatch(actions.createService(data));
  }
}

For some reason when I edit and save, operation works successfully. But when I create and save this method never gets called. These are my redux buttons calling createOrUpdateService method.

             <button className='btn btn-form my-button--orange' type='button'
                 style={{margin: "5px"}}
                 disabled={editable} onClick={() => enableEdit() }>
                 New Service
              </button>
              <button className='btn btn-form my-button--orange' type='button'
                 style={{margin: "5px"}}
                 disabled={!valid || submitting} onClick={() => enableEdit() } >
                 Edit Service
              </button>
              <button className='btn btn-form my-button--orange' type='submit'
                 style={{margin: "5px"}}
                 disabled={!editable} onClick={() => handleEdit(handleSubmit(createOrUpdateService)) } >
                 Save
              </button>

This is handleEdit method -

const handleEdit = (editCallBack) => {
    if (editable) {
      editCallBack()
    }
    toggleEditable();
  }

I am wondering if editCallback() can involve createOrUpdateService() for "Edit Service" then why not for "New Service"? I am wondering how can I invoke multiple submits from same form.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The problem was submission was not successful if props.invalid is true. In my case for create props.invalid was true, while for edit it was false. So I looked back my validations and realized that I am having validation for "id" field. Which will be null for creation.

I removed the validation and it worked fine.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!