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

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

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 Denunciar

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