How to pass a value to hidden input ?

Create form :

@if (isset($id))
    {!! Form::hidden('edition', $id) !!}
@endif

I got the form id by url like this :

<a href="../journal/create?edition={{$edition->id}}" class="btn btn-primary">Add Journal</a>

(当我点击AddJournal按钮时,它会在url处显示一个带有版本id的创建表单)

控制器是:

$id = $request->get('edition');
        $journal = Edition::findOrFail($id)->journal()->create($input);

The result gave me this error "No query results for model [App\Edition]."

推荐答案

通常,这在Blade 模板中使用.

Just pass the name and value to the method.

{{ Form::hidden('invisible', 'secret') }}

This creates a very simple element which looks like the following.

<input name="invisible" type="hidden" value="secret">

To add other attributes, pass a third argument to the method. This third argument must be an array.

{{ Form::hidden('invisible', 'secret', array('id' => 'invisible_id')) }}

现在,输入有一个id属性.

<input id="invisible_id" name="invisible" type="hidden" value="secret">

Check out : Creating a Hidden Input Field


If still not work check you project have Laravel Collective installed

In controller method check

public function store(Request $request)
{
    $name = $request->input('name');
}

Laravel相关问答推荐

保存很多模型太慢

Laravel-如何按第三表关系对数据进行分类

有没有办法使用laravel EXCEL读取和修改EXCEL文件?

在GitHub操作中缺少PHPStan和PHPMD输出,但在本地存在

使用枢轴插入多对多时的Laravel问题

laravel Eloquent 模型更新事件未触发

如何在 laravel 5.2 中显示 500 内部服务器错误页面?

Laravel 5 make:控制器在应用程序文件夹而不是控制器文件夹中创建控制器

使用 Laravel 限制多态多对多关系中的相关记录

静态密码在默认的 Laravel 用户工厂中是如何工作的?

Laravel 路由将变量传递给控制器

Laravel 查询构建器 - 如何按别名分组,或进行原始 groupBy

路由模型绑定不起作用

Laravel 说 Auth guard [] 没有定义

如果值存在于另一个字段数组中,Laravel 验证规则

Class类 App\Http\Controllers\Auth\Request 不存在.

如何在 Laravel 5 中的每个相关输入字段旁边显示验证错误?

Eloquent 模型不更新 updated_at 时间戳

Laravel 中的 isDirty() 是什么意思?

将图像保存在公共文件夹中,而不是存储 laravel 5