Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Radio button in Laravel 5.4

I have a register form where users can sign up and I recently added two radio buttons to define users type.

Example:

(*) I want to buy   (*) I want to sell

Here's how I was thinking to do this: I added a boolean field in the users table and I was thinking to check if I want to buy is checked then I store 1 in the database if the other one is checked then I store 0.

The thing is, I'm not sure how to check in the controller if the radio button is selected or not.. I tried to look in the documentation and on google but all I found were some ideas using the Form facade which as I know is no longer used in 5.4...

like image 269
Ovidiu G Avatar asked Feb 18 '17 17:02

Ovidiu G


1 Answers

HTML

  {{ Form::radio('result', 'buy' , true) }}
  {{ Form::radio('result', 'sell' , false) }}

Without Form Facade

  <input type="radio" name="result" value="buy" checked>
  <input type="radio" name="result" value="sell">

Controller

  $fields = Input::get('result');
  if($fields == 'buy'){
  // logic
  }
  else{
  // logic
  } 
like image 69
Pramod Patil Avatar answered Nov 14 '22 03:11

Pramod Patil