Yii2 textinput() and httml::submitButton in the same row

Asked

Viewed 207 times

0

I need an example in Yii2 that allows me to put some submitButton and textinput() in the same line, as the example below:

Exemplo da linha

part of my code that mounts the buttons :

<?= Html::submitButton(Yii::t('app','Voltar'), ['class' => 'btn btn-primary', 'name' => 'voltar','style' => 'width:78px']) ?>
    <?= Html::submitButton(Yii::t('app','Atualizar'), ['class' => 'btn btn-primary', 'name' => 'atualizar','style' => 'width:80px']) ?>
    <?= Html::Button(Yii::t('app','Apagar'), ['id'=>'btn-confirm','class' => 'btn btn-danger', 'name' => 'apagar','style' => 'width:78px','disabled'=>$desabilitaAPAGA]) ?>
    <?php
    if($habilitaLIGA)
        echo Html::submitButton(Yii::t('app','Ativar'), ['class' => 'btn btn-success', 'name' => 'ativar','style' => 'width:78px']);
    ?>
    <?php
    if($habilitaDESLIGA)
        echo Html::submitButton(Yii::t('app','Desativar'), ['class' => 'btn btn-success', 'name' => 'desativar', 'style' => 'width:80px']);
    ?>
    <?= Html::submitButton(Yii::t('app','Gráfico'), ['class' => 'btn btn-primary', 'name' => 'grafico','style' => 'width:80px']) ?>

I’m waiting for an example to help me.

  • And what your buttons look like?

  • Textinput and write button are on the bottom line, with the insertion of this code below:

  • <div class="input-group"> <?= $form->field($model, raw_data')->textInput(['style'=>'width:100px']);? > <?= Html::submitButton(Yii::t('app','write'), ['class' => 'btn btn-Primary', 'name' => 'write','style' => 'width:80px']) ? > </div>

1 answer

1


You can put each control inside a div and line them up on the left as well as define its size and the space it will have between the other. For example:

<div  style="float:left; margin-left: 10px; width: 100px"> 
    <?= Html::submitButton(Yii::t('app','Voltar'), ['class' => 'btn btn-primary', 'name' => 'voltar','style' => 'width:78px']) ?>
</div>
<div  style="float:left; margin-left: 10px; width: 100px"> 
    <?= Html::submitButton(Yii::t('app','Atualizar'), ['class' => 'btn btn-primary', 'name' => 'atualizar','style' => 'width:80px']) ?>
</div>
<div  style="float:left; margin-left: 10px; width: 100px"> 
   <?= Html::Button(Yii::t('app','Apagar'), ['id'=>'btn-confirm','class' => 'btn btn-danger', 'name' => 'apagar','style' => 'width:78px','disabled'=>$desabilitaAPAGA])
</div>

You can also create a specific setting within the css for the class you will use on the button, so you will not need to repeat the settings like width, margin-left, margin-right, float, etc...

I hope I’ve helped.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.