Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

318
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda