如何从刀片模板调用控制器中的功能

时间:2020-08-27 07:49:02

标签: laravel radio-button

我试图从单选按钮的onlick函数中的刀片文件中调用控制器函数(以及传递一些变量)。但是,我似乎还无法从刀片文件中的控制器调用该函数(单击选择时什么也没有发生)

我的刀片文件

<div class="container box">
      @foreach($questionList as $post)
      <div class = "test">
        <p>
          <strong>{{$post->getQuestionId()}}.  {{$post->getQuestion()}}</strong>
          <br>
        </p>
        <span>
           <input type="radio" name="{{$post->getQuestionId()}}" href="{{action('questionController@updateChoice',$data->$post->getQuestionId())}}" value="a">
           <label for="a">{{$post->getChoiceA()}}</label>
        </span>
        <span>
           <input type="radio" name="{{$post->getQuestionId()}}" value="b"> <label for="b">{{$post->getChoiceB()}}</label></span>
        <span>
          <input type="radio" name="{{$post->getQuestionId()}}" value="c"> 
          <label for="c">{{$post->getChoiceC()}}</label>
         </span>
        <span>
          <input type="radio" name="{{$post->getQuestionId()}}" value="d"> 
          <label for="d">{{$post->getChoiceD()}}</label>
        </span>
        <br>
      </div>
      @endforeach
  </div>

我的questionController方法

   function updateChoice($id)
    {
     /// do function in here
    }

我还需要做其他事情吗?

0 个答案:

没有答案