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

186
Vistas
Update automaticaly switch button on checked

I have issues in my project. In deed, I want to update automatically a switch button when I check it. The case that I have is that when I click on the switch button, the page is refresh but the value is not changed.

my code :

<div class="col-4 text-left">
     <form  id="form" class="was-validated" method="POST" action="{{ route("admin.patients.update", [$patient->id]) }}" enctype="multipart/form-data">
     @method('PUT')
     @csrf
         <div style="float: right">
              <label class="switch">
                  <input type="checkbox" onchange="$('#form').submit();" name="cas_suivi" id="cas_suivi" type="checkbox" {{  ($patient->cas_suivi == "cas_suivi" ? ' checked' : '') }} >
                      <div class="slider"></div>
              </label>
          </div>
       </form>
     </div>

the controller:

public function update(UpdatePatientRequest $request, Patient $patient) { $patient->update($request->all()); return view( 'admin.patients.show', (compact('patient'))->with('success', 'Le patient a bien été modifié'); }
over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

The result is:

    array:3 [▼
    "_method" => "PUT"
    "_token" => "Vo93U0F1uO1Ji7r03uVuENgq8JylZsEV5u6zQfRV"
    "cas_suivi" => "on"
    ]
over 4 years ago · Santiago Trujillo Denunciar

0

After updating the table you need to redirect to the page again.

//change the route name if necessary

public function update(UpdatePatientRequest $request, Patient $patient) 
    { 
        $patient->update($request->all()); 
        return redirect()
        ->route('admin.patients.index')
        ->with('success', 'Le patient a bien été modifié'); 
    }
over 4 years ago · Santiago Trujillo 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