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

276
Visualizações
how to get the type of input in laravel

I have input in my form and I want to save the name, type, and value of that input in my database when the user saves the form.

I'm getting the name and value of the input but can't get the type.

I've tried it with JavaScript and it works. But I want to save it using Laravel in the controller. Is there any way that I can get the type?

using JavaScript: document.getElementsByName("name")[0].type returns "text".

Thanks in advance.

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

The only thing which you can related to each input field is it name and it value. To have type of each field you can use hidden field which will have name like type_of_name for a field which has name name and type_of_password for a field which has name password and so on. as all that field will be pass to the request you can access them inside of you controller and get type of each form field by getting input element which as name equal to the field name prefixed with the type_of

Here is a sample code

<form action="" method="post">
   
    <input type="text" name="name">
    <input type="hidden" name="type_of_name" value="text">

    <input type="password" name="password">
    <input type="hidden" name="type_of_password" value="password">
    {{-- etc. --}}
</form>
about 4 years ago · Juan Pablo Isaza Relatório

0

Using the built in php function :

gettype — Get the type of a variable

See this below pseudo code:

$input = "Your Name";

echo gettype($input);
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