2013-08-30 1 views
29

Laravel 블레이드 드롭 다운 목록 클래스 특성이 작동하지 않습니다.Laravel 4 블레이드 드롭 다운 목록 클래스 속성

클래스에 대한 참조를 찾지 못하거나 문서의 선택/드롭 다운 목록에 속성을 할당 할 수 없습니다.

http://www.laravel.com/docs/html#drop-down-lists

예 시도 :

{{ Form::select('product_id', $productList, array('class'=>'form-control')) }} 

{{ Form::select('product_id', $productList, $attributes = array('class'=>'form-control')) }} 

가 모두 같은 HTML을 반환하지만 class 속성없이 :

<select id="product_id" name="product_id"> 
    ... Option Stuff ... 
</select> 

답변

71
{{ Form::select('product_id', $productList, null, array('class' => 'form-control')) }} 

세번째 파라미터는 현재 선택의 열쇠 선택권. 기본값은 null입니다.

+4

감사 .. 이 문서에 간단한 내용이 쓰여졌 으면 좋겠다. – Gravy

+2

항상 소스를 확인할 수 있습니다. 만약 당신이 장엄한 텍스트를 사용한다면'cmd + t'를 치고'FormBuilder'를 입력하십시오. 소스 코드를 직접 변경할 수는 없기 때문에 프레임 워크가 애플리케이션의 일부라는 것을 기억한다고해서 거기에있는 코드에 익숙하지 않아도된다는 의미는 아닙니다. –

0

먼저 얻고, 예를 들면 컨트롤러의 목록을 만들 :

$username_lists = Users::lists('username','id'); 

패스 데이터에 의해 볼 :

return View::make('layouts.customers') 
      ->with('username_lists', $username_lists); 

이제도 얻을 : 그 대

{{ Form::select('username_lists', $username_lists, null, array('class' => 'form-control')) }}