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

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

0

The result is:

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

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 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