title: How to validate radio button/checkbox and must to select one in laravel
body: <p>I'm trying to validate a radio button in Laravel. This is my code, but it doesn't work. </p>
  
  <p>In my case, i have a <strong>dynamic</strong> form with many questions with different of type such as : radio, checkbook, single input, number input,... So I have to use array name for each type of question. For example : name="radio['.$k.']". </p>
  
  <p>In my controller i make validation and $key is the $k value in initial form. </p>
  
  <pre><code>public function rules()
  {
   $rules = [];
  if (Input::has('radio')) {
      foreach (Input::get('radio') as $key =&gt; $val) {
          $rules['radio.' . $key] = 'required';
      }
   }
  if (Input::has('singleinput')) {
              foreach (Input::get('singleinput') as $key =&gt; $val) {
                  $rules['singleinput.'.$key] = 'required|max:10';
                  }
              }
  
  }
  
   public function messages()
      {
          $messages = [];
  
          if (Input::has('radio')) {
        // some code here;
           }
       }
  
  public function answer_store($survey_id, $patient_id)
      {
          $rule = $this-&gt;rules();
          $message = $this-&gt;messages();
          $validator = Validator::make(Input::all(), $rule, $message);
  }
  </code></pre>
  
  <p>In the view: </p>
  
  <pre><code>&lt;input type="radio" name="radio['.$k.']" value="'.$str1.'"&gt;'.$answer-&gt;answer_body
  </code></pre>
  
  <p>My code works with text input type but not with radio &amp; checkbox.
  Anyone can help me?</p>