2016-08-12 11 views
0

ブレードにおける入力フォームとして使用される以下の$ fields配列、観察:ユーザが値を有する場合、「AGENT_ID」一部でフィールド配列の選択フィールドからオプションを事前に選択していますか?

$fields = [ 
    'user_id'   => [ 
     'label' => 'Opportunity Owner' . $req, 
     'type' => 'select', 
     'class' => 'select2', 
     'opts' => User::whereTenantId(tenant()->id)->whereRole('Admin')->get()->lists('name', 'id')->all() 
    ], 
    'name'    => [ 
     'label' => 'Opportunity Name' . $req, 
    ], 
    'agent_id'   => [ 
     'label'  => 'Agent', 
     'type'  => 'select', 
     'class'  => 'select2', 
     'textAsValue' => false, 
     'opts'  => array_replace([0 => '-- Select Sales Rep --'], 
         User::whereTenantId(tenant()->id)->whereRole('Admin')->get()->lists('name', 'id')->all()), 
    ], 
    'description'  => [ 
     'label' => 'Description', 
     'type' => 'textarea' 
    ], 
    [ 
     'type' => 'submit', 
     'label' => 'Save', 
     'class' => 'btn btn-primary !important' 
    ] 

]; 

を、I値を事前に選択したいです事前に割り当てられた。私はユーザーから情報を取得する方法を知っていますが、 'agent_id'フィールド内の配列のオプションを '選択'する方法については迷っています。選択肢に表示するすべてのオプションが必要ですが、ユーザーにリンクされているagent_id番号に基づいて「選択」したいと思っています。私は次のように試しました:

しかし、これはうまくいきませんでした。これをどうやってやることができますか?

答えて

0

インデックスなしで選択した値を追加します。
試用:

'agent_id'   => [ 
     'label'  => 'Agent', 
     'type'  => 'select', 
     'class'  => 'select2', 
     'textAsValue' => false, 
     'opts'  => array_replace([0 => '-- Select Sales Rep --'], 
         User::whereTenantId(tenant()->id)->whereRole('Admin')->get()->lists('name', 'id')->all()), 
     {{appropriate number here}} 

    ], 
関連する問題