Laravel 4 Blade Form Formatting (Hidden Input)

前端 未结 2 781
无人共我
无人共我 2021-01-27 18:20

I have an \"artist\" resource, and on the show route page I have a form. I am using Laravel Blade syntax. As part of this form, I am trying to send the page ID to the back end

2条回答
  •  逝去的感伤
    2021-01-27 18:56

    So anything inside the blade tags {{ }} is treated as standard PHP. Using further {{ }} inside existing blade tags is just going to throw a big error.

    Because anything inside the blade tags is treated as PHP you can simply do the following

    {{ Form::hidden('artist-id', null, ['id' => $artist->id]) }}
    

    Although posting that input isn't going to give you the value you want, because the value supplied is null. The id attribute is the html ID given to the html attribute. You need the following to set the value on the input, which will then be posted in with your form data

    {{ Form::hidden('artist-id', $artist->id) }}
    

提交回复
热议问题