Laravel 4,->withInput(); = 未定义的偏移量:0

2024-06-03

我在这里和 Laravel 论坛上进行了长时间的搜索,但我找不到这个问题的答案。->withInput()咳出Undefined offset: 0.

对于上下文:

控制器

public function getJobs()

        {
            $position_options = DB::table('jposition')->lists('friendly','id');
            $category_options = DB::table('jcategory')->lists('friendly','id');
            $location_options = DB::table('jlocation')->lists('friendly','id');



            $result = $query->get();
            return View::make('jobsearch.search', array('position_options' => $position_options, 'category_options' => $category_options, 'location_options' => $location_options))->withInput();

        }

View

<form action="{{ action('JobsearchController@getJobs') }}" method="post">
  <div class="row">
    <div class="large-8 columns">
      <input type="text" name="realm" placeholder="Keywords/Skills" />
    </div>
    <div class="large-4 columns">
       {{ Form::select('category', $category_options , Input::old('category')) }}
    </div>
  </div>
  <div class="row">

    <div class="large-4 columns">
      {{ Form::select('location', $location_options , Input::old('location')) }}
    </div>


    <div class="large-4 columns">
      {{ Form::select('type', $position_options , Input::old('type')) }}
    </div>
    <div class="large-4 columns">
       <input type="submit" value="Search" style="width:100%; padding-top: .5rem;
padding-bottom: .5rem;" class="button border-btn" />
      </div>


</div>
</form>

现在根据文档,不应该有问题,并且如果以下情况,页面加载正常->withInput();已移除。

最终目标是提供我从上一个问题中收到的答案db:raw 产生的不良结果 https://stackoverflow.com/questions/22001054/undesired-result-from-dbraw并有一个页面加载“过滤”表单并在重新加载时显示相关结果并记住表单中的选择。

提前致谢。

更新: 根据评论,我更新了控制器和路线,结果仍然相同:

路线.php

Route::get('jobs/search', 'JobsearchController@getSearch');

&

Route::post('jobs/search', 'JobsearchController@getJobs');

控制器

 public function getSearch()
        {
                    $position_options = DB::table('jposition')->lists('friendly','id');
            $category_options = DB::table('jcategory')->lists('friendly','id');
            $location_options = DB::table('jlocation')->lists('friendly','id');

            return View::make('jobsearch.search', array('position_options' => $position_options, 'category_options' => $category_options, 'location_options' => $location_options));
        }

        public function getJobs()

        {
            $position_options = DB::table('jposition')->lists('friendly','id');
            $category_options = DB::table('jcategory')->lists('friendly','id');
            $location_options = DB::table('jlocation')->lists('friendly','id');


            return View::make('jobsearch.search', array('position_options' => $position_options, 'category_options' => $category_options, 'location_options' => $location_options))->withInput();

        }

withInput()只是一个方法Redirect班级。它不可用View class.

Calling View.withInput($data)有不同的行为:它将以下键值对传递到您的视图:'input' => $data。这会导致您的代码出现错误,因为您没有向该函数传递任何数据。

要获得您想要的行为,请致电Input::flash()在发表观点之前,而不是打电话withInput()。这将允许您使用Input::old()在您的视图中使用函数来访问数据。

或者,你可以通过Input::all()根据您的观点,并使用input[]在你看来数组:

View::make(...)->withInput(Input::all());

这被翻译成

View::make(...)->with('input', Input::all());
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Laravel 4,->withInput(); = 未定义的偏移量:0 的相关文章

随机推荐

  • 如何在 matplotlib 中设置日期的 xticklabels

    我正在尝试绘制两个列表中的值 x 轴值是日期 到目前为止尝试过这些事情 year 20070102 20070806 20091208 20111109 20120816 20140117 20140813 yvalues 0 5 0 5
  • 是否可以“缩放”WPF RichTextBox 中的文本?

    我注意到 WinForms RichTextBox 有一个ZoomFactor我认为这正是我想要的属性 不幸的是 WPF 变体似乎完全缺少此属性 有什么方法可以实现相同的功能 增加 减少整个文档的可见文本大小而不实际更改底层 RTF Upd
  • Django - 在管理之外使用多对多水平界面

    我正在使用带有 m2m 字段的表单 我希望这个字段看起来像 django 管理站点的水平界面 我该怎么做 谢谢 您需要使用FilteredSelectMultiple widget from django contrib admin wid
  • Flask 装饰器怎么能有参数呢?

    我以与这里相同的方式实现了一个装饰器如何在 Flask 中使用参数创建 python 装饰器函数 用于授权 https stackoverflow com questions 13896650 how to make a python de
  • MiBand 2 可以检测触摸吗?

    我在Github上看过很多非官方的MiBand SDK 例如 https github com Freeyourgadget Gadgetbridge https github com Freeyourgadget Gadgetbridge
  • C++并行排序

    我需要对存储在结构数组中的数据块进行排序 结构体没有指针 每个块都有其计数器编号以及数组中数据块与结构块相等的位置的坐标 例如 如果我们有一个数据数组 我们可以将其分为 4 个 NxN 块 那么在结构块的索引数组中我们有 4 个结构块 每个
  • 当应用程序处于后台时,传递数据的 FCM Intent 在哪里?

    我已经在我的应用程序中实现了 Firebase 并且正在发送带有额外数据的推送 当我的应用程序位于前台时 我正在正确处理数据并显示我自己的通知 但是当应用程序 驻留 未终止 时 Firebase 自动 显示通知时 我在获取数据时遇到问题 根
  • 如何一次执行多个 RSQLite 语句或如何转储整个文件?

    使用 RSQLite 构建 SQLite 数据库 我想一次发送多个语句 这可能吗 为什么要做这些not work sql lt readLines createtables sql dbSendQuery con sql 和 sql lt
  • 快速写入:内存映射文件与 BufferedWriter

    有人对此进行过基准测试吗 我希望尽可能快地写入磁盘 最大限度地减少写入调用的延迟 我想知道写入内存映射缓冲区 通过 buffer put 是否比仅在 Java 端缓冲内容并在缓冲区满后刷新到 fileChannel 更快 这样 一旦缓冲区已
  • 设置属性文本后防止 UILabel 字体自动更改

    我发现如果我将属性文本设置为UILabel 预定义字体将更改为属性文本第一个字符的字体 例如 the font size is set to 20 in Interface Builder println theLabel font poi
  • System.Windows.Controls.WebBrowser、System.Windows.Threading.Dispatcher 和 Windows 服务

    我正在尝试将一些 html 内容渲染为 Windows 服务中的位图 我正在使用 System Windows Controls WebBrowser 来执行渲染 基本渲染设置作为一个独立进程运行 并带有托管控件的 WPF 窗口 但作为服务
  • 如何使用 Python 将 4 个字节解释为 32 位浮点数

    我是 Python 语言的新手 我很难做一些我可以用 C 或 Java 轻松完成的事情 但由于某种原因 在 Python 中做起来似乎很复杂 我的数组中有以下四个字节 按大端顺序 0x64 0xD8 0x6E 0x3F 我事先已经知道这些字
  • 如何使用 Django 了解服务器是否安全(使用 https)

    我正在开发一个基于 Django 的应用程序 我想知道是否有办法知道我的服务器使用的是 http 连接还是 https 我知道使用 import socket if socket gethostname startswith 我可以获取主机
  • 为什么属性装饰器只为类定义?

    tl dr 为什么属性装饰器可以与类级函数定义一起使用 但不能与模块级定义一起使用 我将属性装饰器应用于一些模块级函数 认为它们将允许我仅通过属性查找来调用方法 这特别诱人 因为我正在定义一组配置函数 例如get port get host
  • 在 Colab 中删除后恢复单元格

    我经常在 Colab 中意外删除代码 并且由于某种原因 当我尝试撤消代码删除时 它不起作用 所以基本上 当我这样做时 我想以某种方式恢复我的细胞 有什么办法可以做到这一点 比如看看 Colab 正在运行的代码 因为我的细胞可能还在那里 另一
  • 安装 gstreamer 对 opencv python 包的支持

    我已经从源代码构建了自己的 opencv python 包 import cv2 print cv2 version 打印 3 4 5 现在我面临的问题是关于 opencv 的 VideoCapture 类中的 gstreamer 的使用
  • 有人真正有效地实现了斐波那契堆吗?

    你们中有人曾经实施过斐波那契堆 http en wikipedia org wiki Fibonacci heap 几年前我就这样做了 但它比使用基于数组的 BinHeaps 慢了几个数量级 当时 我认为这是一个宝贵的教训 告诉我们研究并不
  • 编译最新版本l2switch时出现问题

    我想使用较新版本的 l2switch 插件 但是当我尝试编译该项目时 出现以下错误 ERROR Failed to execute goal org apache maven plugins maven compiler plugin 3
  • 增量少吞构建

    在我的办公室 我们使用 gulp 来构建 less 文件 我想改进构建任务 因为在我们最近从事的一个大型项目上构建需要花费一秒钟的时间 这个想法是缓存文件并只传递发生更改的文件 所以我从谷歌开始 发现了 javascript 的增量构建 并
  • Laravel 4,->withInput(); = 未定义的偏移量:0

    我在这里和 Laravel 论坛上进行了长时间的搜索 但我找不到这个问题的答案 gt withInput 咳出Undefined offset 0 对于上下文 控制器 public function getJobs position opt