2017-08-18 3 views

答えて

1

SwitchInputクラスdoes not care undifined値が返されました:

 $model->orientation = 'Portrait'; 
     echo $form->field($model, 'orientation')->widget(SwitchInput::classname(), [ 
      'name' => 'information_orientation', 
      'type' => SwitchInput::RADIO, 
      'value' => 'Portrait', 
      'items' => [ 
       ['label' => 'Portrait&nbsp&nbsp&nbsp', 'value' => 'Portrait'], 
       ['label' => 'Paysage&nbsp&nbsp&nbsp', 'value' => 'Paysage'], 
      ], 
      'pluginOptions' => [ 
       'onText' => 'Oui', 
       'offText' => 'Non', 
       'onColor' => 'success', 
       'offColor' => 'danger', 
       'size' => 'mini' 
      ], 
      'labelOptions' => ['style' => 'font-size: 13px'], 
     ]); 

私が試してみました私はプロパティあなたはそれらのドキュメントによると、それを
を与え、あなたはdocsからoptions配列

echo $form->field($model, 'orientation') 
    ->widget(SwitchInput::classname(), [ 
     'options' => ['name' => 'information_orientation'], 
     'type' => SwitchInput::RADIO, 
.... 

nameをラップする必要があります。

options配列をHTMLウィジェットのinputタグの属性。

編集:
あなたは、次

// to get value: 
$("[name='information_orientation']").val() 

// to check if the switch is or on off 
$("[name='information_orientation']").prop('checked') 
+0

感謝を使用することができますが、今どのように私は、選択されたオプションの値を得ることができますか? – BlackstarMC97

+0

@ BlackstarMC97あなたの最初の入力方法を選択する方法はほぼ正しいです(セレクタとアンダースコアのダッシュ)。 – csminb

+0

例を使って答えを更新しました。$(\ "[name = 'information_orientation']: ").val()そしてそれは私に選択された値を返します。助けてくれてありがとう、 – BlackstarMC97

関連する問題