Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

271
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!