如何将变量提供给我的边栏选项卡并将其保存到变量中


How do I give a variable to my blade and save them to a variable?

我的问题解释起来有点复杂。我正在做一个博客,做了一些类似主题部分的事情。我有一个主题表和一个线程表。在我的线程表中是一个"主题"属性。不,如果我正在做一个新线程,我也想保存主题,用户当前正在。

我带有变量的发送按钮是这样的:

<a href="{{ action('Test''TestController@add', [$thread->thema]) }}">
    <div class="btn btn-primary">Thread hinzufügen</div>
</a>

我的添加路由:

Route::get('/add/{thread}', 'Test''TestController@add');

我的控制器函数只是将我发送到线程创建表单。

我的创建线程 - 表单 :

{!! Former::horizontal_open()->action(action('Test''TestController@store')) !!}
{!! Former::text('thread')->label('Title:')->autofocus() !!}
{!! Former::textarea('content')->label('Content')->rows(10) !!}
{!! Former::large_primary_submit('Add Thread') !!}
{!! Former::close() !!}

好吧,在我按下提交按钮后,线程被保存,但没有主题! :/

根据以下路线:

Route::get('/add/{thread}', 'Test''TestController@add');

您将在 TestController@add 方法中获得$thread->thema,因此您的方法应该能够接收该参数/变量,例如:

public function add($thread)
{
    // Now you may pass the $thread to form and keep the value in a hidden
    // text box, to pass to the for the form, add the $thread using with:
    return view('FormView')->with('thread', $thread);
}

在表单中,创建一个隐藏的输入:

<input type="hidden" name="thread" value="{{ old('thread', $thread) }}" />

或者也许这个(如果它有效,不确定前者):

{!! Former::hidden('thread', old('thread', $thread))->label('Title:')->autofocus() !!}
相关文章: