Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/280.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 你也应该努力在你的文章中正确地格式化代码。为什么OP“试试这个”?一个好的答案总是会有一个解释,说明做了什么以及为什么这样做,不仅是为了OP,而且是为了未来的访客。如果我们不使用表单类呢@foreach($elements as$element\u eac_Php_Laravel_Laravel 5_Blade - Fatal编程技术网

Php 你也应该努力在你的文章中正确地格式化代码。为什么OP“试试这个”?一个好的答案总是会有一个解释,说明做了什么以及为什么这样做,不仅是为了OP,而且是为了未来的访客。如果我们不使用表单类呢@foreach($elements as$element\u eac

Php 你也应该努力在你的文章中正确地格式化代码。为什么OP“试试这个”?一个好的答案总是会有一个解释,说明做了什么以及为什么这样做,不仅是为了OP,而且是为了未来的访客。如果我们不使用表单类呢@foreach($elements as$element\u eac,php,laravel,laravel-5,blade,Php,Laravel,Laravel 5,Blade,你也应该努力在你的文章中正确地格式化代码。为什么OP“试试这个”?一个好的答案总是会有一个解释,说明做了什么以及为什么这样做,不仅是为了OP,而且是为了未来的访客。如果我们不使用表单类呢@foreach($elements as$element\u each){!!$element\u each->name!!}@endforeach给出错误。如果使用form类,则必须安装facade。没有它就不行。Google for laravel form collectivehorse尝试用{{{}更改


你也应该努力在你的文章中正确地格式化代码。为什么OP“试试这个”?一个好的答案总是会有一个解释,说明做了什么以及为什么这样做,不仅是为了OP,而且是为了未来的访客。如果我们不使用表单类呢
@foreach($elements as$element\u each){!!$element\u each->name!!}@endforeach
给出错误。如果使用form类,则必须安装facade。没有它就不行。Google for laravel form collectivehorse尝试用
{{{}
更改
{{}}
谢谢。我一直在寻找这个答案,很高兴找到你的答案:D工作得很好。非常感谢。
$items = Items::all(['id', 'name']);
$items = Items::lists('name', 'id');
$items = Items::where('active', true)->orderBy('name')->lists('name', 'id');
$items = Items::pluck('name', 'id');
$items = Items::where('active', true)->orderBy('name')->pluck('name', 'id');
public function create()
{
    $items = Subject::all(['id', 'name']);
    return View::make('your view', compact('items));
}
<div class="form-group">
  {!! Form::Label('item', 'Item:') !!}
  <select class="form-control" name="item_id">
    @foreach($items as $item)
      <option value="{{$item->id}}">{{$item->name}}</option>
    @endforeach
  </select>
</div>
$datas = Items::lists('name', 'id');
$items = array();

foreach ($datas as $data)
{
    $items[$data->id] = $data->name;
}

return \View::make('your view', compact('items',$items));
<div class="form-group">
    {!! Form::label('item', 'Item:') !!}
    {!! Form::select('item_id', $items, null, ['class' => 'form-control']) !!}
</div>
 $campaignStatus = Campaign::lists('status', 'id');
return view('management.campaign.index', compact('campaignStatus'));
{!! Form::select('status', $campaignStatus, array('class' => 'form-control')) !!}
$items = Items::lists('name', 'id');
$items->prepend($value, $key = null);
$items = Items::pluck('name', 'id');

{!! Form::select('items', $items, null, ['class' => 'some_css_class']) !!}
id name
1  item1
2  item2
3  item3
4  item4
<select>
<option value="1">item1</option>
<option value="2">item2</option>
<option value="3">item3</option>
<option value="4">item4</option>
</select>
$items= Items::pluck('name', 'id')->toArray();
return view('your view', compact('items', $items));
{{ Form::select('organization_id', $items, null, []) }}
$products = Product::pluck('name', 'id');

return view('main.index', compact('products'));
{{ Form::select('id', $products, null, ['class' => 'form-control']) }}
{{ Form::select('apartment_id', \App\Apartment::all()->pluck('apartment_name', 'apartment_id')->toArray(), null,['class'=>'select2 form-control', 'multiple'=>'multiple','required','id' => 'apartment_id']) }}
public function create()
{
    $items = array(
        'itemlist' =>  DB::table('itemtable')->get()
      );

    return view('prices.create', $items);
}
<select name="categories" id="categories" class="form-control">
  @foreach($itemlist as $item)
    <option value="{{ $item->id }}">{{ $item->name }}</option>
  @endforeach
</select>
<select>
 <option value="1">item1</option>
 <option value="2">item2</option>
 <option value="3">item3</option>
 ...
</select>
$items = Item::pluck('name', 'id')->toArray();

{{ Form::select('item_id', [null=>'Please Select'] + $items) }}
public function create()
{
    $countries =  Country::pluck('country_name','id');
    return View::make('test.new')->with('countries', $countries);
}
{{  Form::select('testname',$countries,null,['class' => 'required form-control select2','id'=>'testname']) }}
<option value="" selected="selected">--Select  Country--</option>
https://stackoverflow.com/a/51324218/8487424
public static  function toDropDown($tableName='',$nameField='',$idField='',$defaultNullText='--Select--')
{
    if ($idField == null)
    {
        $idField="id";
    }

    $listFiledValues = DB::table($tableName)->select($idField,$nameField)->get();

            $selectArray=[];
            $selectArray[null] = $defaultNullText;
            foreach ($listFiledValues as $listFiledValue) 
            {
                $selectArray[$listFiledValue->$idField] = $listFiledValue->$nameField;
            }
            return $selectArray;
        }
public function create()
    {
      $countries = Country::toDropDown('countries','name','id','--Select  Country--');
      return View::make('test.new')->with('countries', $countries);
    }
 {{  Form::select('testname',$countries,null,['class' => 'required form-control select2','id'=>'testname']) }}
 public function addCustomerLoyaltyCardDetails(){
        $loyalityCardMaster = DB::table('loyality_cards')->pluck('loyality_card_id', 'loyalityCardNumber');
        return view('admin.AddCustomerLoyaltyCardScreen')->with('loyalityCardMaster',$loyalityCardMaster);
    }
 <select class="form-control" id="loyalityCardNumber" name="loyalityCardNumber" >
       @foreach ($loyalityCardMaster as $id => $name)                                     
            <option value="{{$name}}">{{$id}}</option>
       @endforeach
 </select>
<div class="row mb-2">
    <label for="status" class="mr-2">Status:</label>
    {{ Form::select('status', 
                $todoStatuses->pluck('status', 'id'), 
                null, 
                ['placeholder' => 'Status']) }}
</div>