2016-04-12 10 views
0

Ich arbeite auf yii2 Bootstrap aktive Formular und ich muss mehrere Eingaben in einer Formulargruppe zu halten.Wie mehrere Felder und Label in einer Formulargruppe in yii2 bootstrap aktivem Formular zu halten

wie

<div class="form-group field-phn required"> 
        <label class="control-label" >Home Phone</label> 
        <select id="dialCode" class="form-control" name="AddPatientForm[home_dial_code]"> 
         <option value="2">355,ALB</option> 
         <option value="3">213,DZA</option> 
         <option value="6">244,AGO</option> 
         <option value="224">971,ARE</option> 
        </select> 
        <input type="text" id="home_phn" class="form-control" name="AddPatientForm[home_phn]"> 
        <p class="help-block help-block-error"></p> 
        </div> 

PHP-Code ich versuche ist

<?php echo \yii\bootstrap\Html::activeLabel($objAddPatientFrm, 'home_phn') ?> 
<?php echo $objActiveForm->field($objAddPatientFrm, 'home_dial_code', [ 'inputOptions' => [ 'id' => 'dialCode']])->dropDownList($dialCodeArray)->label(false); ?> 
<?php echo $objActiveForm->field($objAddPatientFrm, 'home_phn', [ 'inputOptions' => [ 'id' => 'home_phn']]); ?> 

Aber der Ausgang

<label for="addpatientform-home_phn">Home Phn</label>     <div class="form-group field-dialCode required"> 

<select id="dialCode" class="form-control" name="AddPatientForm[home_dial_code]"> 
<option value="2">355,ALB</option> 
<option value="3">213,DZA</option> 
<option value="6">244,AGO</option> 
<option value="224">971,ARE</option> 
</select> 

<p class="help-block help-block-error"></p> 
</div> 
        <div class="form-group field-home_phn required"> 

<input type="text" id="home_phn" class="form-control" name="AddPatientForm[home_phn]"> 

<p class="help-block help-block-error"></p> 
</div> 

beiden Eingänge und Label in separater Form Gruppe zu halten ist.

Bitte schlagen Sie vor, was kann ich tun?

+0

Haben Sie eine Lösung für dieses? –

Antwort

1

Verwendung folgender Weise Formen anzuzeigen:


 

 
// With 'default' layout you would use 'template' to size a specific field: 
 
echo $form->field($model, 'demo', [ 
 
    'template' => '{label} <div class="row"><div class="col-sm-4">{input}{error}{hint}</div></div>' 
 
]); 
 

 
// Input group 
 
echo $form->field($model, 'demo', [ 
 
    'inputTemplate' => '<div class="input-group"><span class="input-group-addon">@</span>{input}</div>', 
 
]);
Hoffe, es wird helfen ..

Verwandte Themen