dongwan0574 2017-06-29 10:55
浏览 59
已采纳

Laravel多个表单属性需要保存在数据库中

I'm using this view. What I need is fill the database with complete name.

enter image description here This is the view code segment.

<label>Name with Initials</label>
<div class="input-group">
  <span class="input-group-addon">
    <select id="name_with_initials" name="name">
      <option selected="selected" value="mr">Mr.</option>
      <option value="mrs">Mrs.</option>
      <option value="miss">Miss.</option>
    </select>
  </span>
  <input type="text" name="name_with_initials" class="form-control" placeholder="Name with Initials">
</div>

Here is the store function in controller.

$registerdetails = new registerdetails;
$title = Input::get('name');
$name  = Input::get('name_with_initials');
$name_with_initials = $title.' '.$name;
$registerdetails ->name_with_initials = $request ->name_with_initials;

My model attribute for that is name_with_initials

This works fine,but save only the name not as mr mrs why is that ?

  • 写回答

1条回答 默认 最新

  • dqdjfb2325 2017-06-29 10:59
    关注

    you have error in this line, here you are storing the complete name in $name_with_initials variable but at the time of storing still you are storing the data which came through request. change this line

    $registerdetails ->name_with_initials = $request ->name_with_initials;
    

    with

    $registerdetails ->name_with_initials = $name_with_initials;
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度