I am struggling to setup, what I thought would be a very straightforward, layout.
I am using Yii2 to generate a form. For the most part all is well, but I need to setup to form fields so they are side by side in a column. I have one form field for feet and one for inches, so I'm looking to have the label followed by the feet field and ' and then the inched field and "
Now, by default my Yii2 is generating (I've tried tons of mutations, but thought I'd post the basic generated code then what I may or may not have messed up).
<div class="col-md-4">
<div class="form-group field-projects-loadlength has-success">
<label class="control-label col-md-4" for="projects-loadlength">Length</label>
<div class="col-sm-6">
<input type="text" id="projects-loadlength" class="form-control" name="Projects[LoadLength]" value="120.00" tabindex="32" aria-invalid="false">
<p class="help-block help-block-error "></p>
</div>
</div>
<div class="form-group field-projects-loadlength has-success">
<div class="col-sm-6 col-sm-offset-3">
<input type="text" id="projects-loadlength" class="form-control" name="Projects[LoadLength]" value="120.00" tabindex="34">
<p class="help-block help-block-error "></p>
</div>
</div>
</div>
I just can't get the CSS, or perhaps the HTMl right? I am using BootStrap 3.
The initial div col-md-4 is the container within which I wish to place my 2 form fields side by side. It is a 3 column setup (each a col-md-4 within a row), 1st column will house length, 2nd width & the 3rd the height
My actual Yii2 code is
<div class="col-md-4">
<div class="row">
<div class="form-group form-inline">
<?php
echo $form->field(
$model,
'LoadOverHang',
[
'options' => ['class' => 'col-md-8 no-padding'],
'inputOptions' => [
'value' => Yii::$app->formatter->asInteger($model->LoadOverHang),
'tabIndex'=>'50',
],
]
)->textInput();
echo "'";
?>
<!-- </div>
<div class="col-md-4" style="margin-left: 2px !important;"> -->
<?php
echo $form->field(
$model,
'LoadOverHang',
[
'inputOptions' => [
'value' => Yii::$app->formatter->asInteger($model->LoadOverHang),
'tabIndex'=>'52',
],
'options' => ['class' => 'col-md-4'],
]
)->textInput()->label(false);
echo '"';
?>
</div>
</div>
</div>
Your help is truly greatly appreciated.
Based on feedback, I tried the following, but still end up with the field split on 2 lines, not side by side?
<div class="column">
<div class="row">
<div class="col-md-4">
<div class="row">
<div class="col-xs-6 form-group field-projects-loadoverhang">
<label class="control-label" for="projects-loadoverhang"> Overhang</label>
<input type="text" id="projects-loadoverhang" class="form-control" name="Projects[LoadOverHang]" value="0" tabindex="50">
<p class="help-block help-block-error "></p>
</div>
<div class="col-xs-6 form-group field-projects-loadoverhang">
<input type="text" id="projects-loadoverhang" class="form-control" name="Projects[LoadOverHang]" value="0" tabindex="52">
<p class="help-block help-block-error "></p>
</div>
</div>
</div>
</div>
</div>
HTMLblock is the one you want to follow using theActiveForm? i cant figure that out - Muhammad Omer Aslam