I am following a tutorial and it is using bootstrap. I am not sure how I would resize textbox for Lan_Id
, Name
and Employee_Number
in it. I think, I am starting to understand Yii framework.
Here is the view 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 model UserForm.php
:
<?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'],
];
}
}
If you want to change the input text field length:
<?= $form->field($model,'Lan_Id')->textInput(['maxlength'=>10]);?>
Above code limits the maximum length of characters to 10.
But if you want to change the input text field size:
<?= $form->field($model,'Lan_Id')->textInput(['style'=>'width:100px']);?>
Above code changes the input text field width to 100px
. You can also have both:
<?= $form->field($model,'Lan_Id')->textInput(['maxlength'=>10,'style'=>'width:100px']);?>
It is highly recommended to take a look at Yii2
's official document: http://www.yiiframework.com/doc-2.0/yii-widgets-activefield.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With