在Laravel中,如果在控制器中使用/ else

时间:2019-12-12 13:00:49

标签: php laravel laravel-5 laravel-5.6

我正在尝试将值从视图传递到控制器,但它不起作用,仅发送了“ APPROVED”

我的观点

<div class="form-group row">
  <label for="colFormLabelLg" class="col-md-2 col-sm-3 control-label control-label-lg"><b>DIGITAL SIGNATURE</b></label>
  <div class="col-md-3">
    <div  class="form-group" id=digital_signature > 
      <select  class="form-control" name="digital_signature" value="{{ old('digital_signature') }}" required autofocus  >
        <option value=""></option>
        <option style="color:green">WITH DIGITAL SIGNATURE</option>
        <option style="color:green">WITHOUT DIGITAL SIGNATURE</option>
      </select>
    </div>
  </div>
</div> 

我的控制器

public function new_approvel_update(Request $request, $id)
{  
    if($request->digital_signature == 'WITH DIGITAL SIGNATURE')
    {
          $input= Student::Where('delete_status','NOT DELETED')->find($id);
          $input['center_approved'] = strtoupper ('APPROVED');
          $input['date_of_join'] = $request->date_of_join;   
    } elseif($request->digital_signature == 'WITHOUT DIGITAL SIGNATURE') {     
          $input= Student::Where('delete_status','NOT DELETED')->find($id);
          $input['center_approved'] = strtoupper ('NOT-APPROVED');
          $input['date_of_join'] = $request->date_of_join;
    }

  $certificate->save();

  return redirect('new_application')->with('success',' APPLICATION APPROVED SUCCESSFULLY .');
}

1 个答案:

答案 0 :(得分:0)

option的{​​{1}}标记中,您没有使用select属性。因此它将null传递给控制器​​。

如下更改选项标签:

value

更改控制器:

<option value="APPROVED" style="color:green">WITH DIGITAL SIGNATURE</option>
<option value="NOT-APPROVED" style="color:green">WITHOUT DIGITAL SIGNATURE</option>