YiI Framwork resizing a text box in a form

I follow the tutorial and it uses download. I am not sure how to resize the text box for Lan_Id, Name and Employee_Number. I think I'm starting to understand the structure of Yii.

here is the view of userForm.php

<?php use yii\helpers\HTML; use yii\widgets\ActiveForm; ?> <?php if(Yii::$app->session->hasFlash('success')) { echo Yii::$app->session->getFlash('success'); } ?> <?php $form = ActiveForm::begin();?> <?= $form->field($model,'Lan_Id');?> <?= $form->field($model,'Name');?> <?= $form->field($model,'Employee_Number');?> <?= Html::submitButton('Submit', ['class'=>'btn btn-success']); 

Here is the UserForm.php model

 <?php namespace app\models; use yii\base\Model; class UserForm extends Model { public $Lan_Id; public $Name; public $Employee_Number; public function rules() { return [ [['Lan_Id','Name','Employee_Number'],'required'], ]; } } 
+6
source share
1 answer

If you want to change the length of the input text box:

  <?= $form->field($model,'Lan_Id')->textInput(['maxlength'=>10]);?> 

Above the code, the maximum character length is limited to 10.

But if you want to resize the input text box:

  <?= $form->field($model,'Lan_Id')->textInput(['style'=>'width:100px']);?> 

Above the code, the width of the input text field is 100px to 100px . You can also use both options:

  <?= $form->field($model,'Lan_Id')->textInput(['maxlength'=>10,'style'=>'width:100px']);?> 

We strongly recommend that you familiarize yourself with the Yii2 : http://www.yiiframework.com/doc-2.0/yii-widgets-activefield.html

+12
source

Source: https://habr.com/ru/post/979734/


All Articles