【问题标题】:How to get paramter from url and check in view?如何从 url 获取参数并签入视图?
【发布时间】:2017-02-02 20:08:57
【问题描述】:

我有这个网址:

http://test.dev/search?publishing_types[]=Selling&priceFrom=0&priceTo=300000&areaFrom=0&areaTo=300000&floors[]=2&yearFrom=1900&yearTo=2017

现在我想要的是这样的:

  <input type="checkbox" class="preventUncheck" name="publishing_types[]" id="toggle-on{{ $index }}" value="{{ $prop_type }}"  @if (publishg_types== Selling) {!! "checked" !!} @endif >

  <input type="checkbox" class="preventUncheck" name="publishing_types[]" id="toggle-on{{ $index }}" value="{{ $prop_type }}"  @if (publishg_types== Reng) {!! "checked" !!} @endif >

所以我想要检查复选框,如果 publishing_types == Selling 和/或 publishing_types == Rent 从 url 检查复选框

【问题讨论】:

  • 如果你将$request['NAME']传递给你的方法,你可以简单地使用它,否则你必须传递它
  • 在视图中我收到此错误然后未定义变量:请求
  • request()-helper 函数与request('publishing_types')一起使用
  • 是的,在视图中你必须像@Sebastian 所说的那样使用request() 函数

标签: laravel laravel-5 laravel-5.2


【解决方案1】:

像这样使用request() 助手:

<input type="checkbox" class="preventUncheck" name="publishing_types[]" id="toggle-on{{ $index }}" value="{{ $prop_type }}"  @if (in_array('Selling', request(publishg_types)) {!! "checked" !!} @endif >

<input type="checkbox" class="preventUncheck" name="publishing_types[]" id="toggle-on{{ $index }}" value="{{ $prop_type }}"  @if (in_array('Reng', request(publishg_types)) {!! "checked" !!} @endif >

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-12-11
    • 2017-08-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-13
    • 1970-01-01
    • 2012-06-01
    相关资源
    最近更新 更多