dos8410 2018-08-26 10:01
浏览 152

如何在laravel中处理多个动态表单字段

I am working on a result management system in laravel, in which a student is enroll in one discipline which is divided in to 8 semester and each semester have multiple courses, these courses are divided in 3groups "compulsory, selective and specialization subject". I made a form through which I am collecting subject marks in a semester. Here is the following code of controller function.

public function add_mid_marks($rollno, $semester)
{
  // getting student by rollno and current status is live
  $student = Student::where('rollno', $rollno)->where('current_status', 1)->firstOrFail();
  // getting courses
  // compulsory courses
  $compulsory = Course::where('discipline_id', $student->discipline_id)
            ->where('semester', $student->current_semester)
            ->where('active', 1)->where('group', 'compulsory')->get();
  // selective courses
  $selective = Course::where('discipline_id', $student->discipline_id)
            ->where('semester', $student->current_semester)
            ->where('active', 1)->where('group', 'selective')->get();
  // group courses
  $groups = Course::distinct()->where('discipline_id', $student->discipline_id)
            ->where('semester', $student->current_semester)
            ->where('active', 1)->where('group','<>' ,'selective')
            ->where('group', '<>', 'compulsory')->pluck('group');
  return view('mid_marks.add_mid_marks', compact('student', 'compulsory', 'selective', 'groups'));
}

following is code from the view code here I want to arrange mid marks and sessional marks fields, but did not get how to arrange and how to name that so that I can easily process data in the controller:

<table class="table" id="compulsory-subject">
    <thead>
      <tr>
        <th>Course Name</th>
        <th>Mid Marks</th>
        <th>Sessional Marks</th>
      </tr>
    </thead>
    <tbody>
      {{--Compulsory Courses--}}
      @if ($compulsory)
        <tr>
        @foreach ($compulsory as $c_s)
          <td>
            <input type="hidden" name="course_id" value="{{$c_s->id}}">
          </td>
          <td>
            <input type="hidden" name="" value="">
          </td>
          <td>
            <input type="hidden" name="" value="">
          </td>  
        @endforeach
      @endif
    </tr>

here is the function I want to process submitted date:

public function store_mid_marks(Request $request)
{
    //storing logic goes here
}

I will grateful for you help, Thank you.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 NAO机器人的录音程序保存问题
    • ¥15 C#读写EXCEL文件,不同编译
    • ¥15 MapReduce结果输出到HBase,一直连接不上MySQL
    • ¥15 扩散模型sd.webui使用时报错“Nonetype”
    • ¥15 stm32流水灯+呼吸灯+外部中断按键
    • ¥15 将二维数组,按照假设的规定,如0/1/0 == "4",把对应列位置写成一个字符并打印输出该字符
    • ¥15 NX MCD仿真与博途通讯不了啥情况
    • ¥15 win11家庭中文版安装docker遇到Hyper-V启用失败解决办法整理
    • ¥15 gradio的web端页面格式不对的问题
    • ¥15 求大家看看Nonce如何配置