Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

311
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda