【问题标题】:Laravel blade checkbox creating curly bracesLaravel刀片复选框创建花括号
【发布时间】:2017-02-13 06:41:40
【问题描述】:

我在 Laravel 5.3 中使用了一个超级简单的复选框表单:

@extends('layout')

@section('content')
    <h1>Hello</h1>
    @foreach($sorts as $sort)
        <div class="checkbox">
            <label>
                {{!! Form::checkbox('agree', 'yes', array($sort => 'Country')) !!}} {{ $sort->Region }}
            </label>
        </div>
    @endforeach
@stop

它正在用这个打印复选框:

{}非洲 - 北非

那些花括号是怎么回事?

我正在尝试从数据库中获取数据,并为每一行打印$Region。哪个正在工作。但是 Laravel 中复选框的可用文档和解释没有提到这一点。我错过了什么?

顺便说一句,这是控制器:

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use DB;
use App\Http\Requests;

class SortController extends Controller
{
    public function index(){
        $sorts = DB::table('list_countries')->get();
        return view('Sort', compact('sorts'));
    }
}

这是路线:

Route::get('Sort', 'SortController@index');

【问题讨论】:

    标签: laravel laravel-5 checkbox laravel-blade


    【解决方案1】:

    你需要矫正你的牙套

    这是错误的

    {{!! Form::checkbox('agree', 'yes', array($sort => 'Country')) !!}}
    

    这是正确的

    {!! Form::checkbox('agree', 'yes', array($sort => 'Country')) !!}
    

    Laravel Documention

    【讨论】:

    • 哦!你把它合二为一了!谢谢。任何地方都没有提到这一点。
    【解决方案2】:

    代替

    {{!! ... !!}}

    使用

    {!! .. !!}

    【讨论】:

      猜你喜欢
      • 2018-09-22
      • 2015-01-14
      • 2018-04-19
      • 2016-01-05
      • 2015-06-19
      • 2021-12-21
      • 2019-10-29
      • 1970-01-01
      • 2015-04-14
      相关资源
      最近更新 更多