ferrylukito
(Ferrylukito2003)
December 9, 2013, 2:47am
1
I can’t put css class like this
<?= $form->field($model, 'ProductCode', ['class' => 'col-lg-3'])->textInput(['maxlength' => 100]) ?>
Fatal Error – yii\base\ErrorException
Class 'col-lg-3' not found
1. in C:\xampp\htdocs\fems\vendor\yiisoft\yii2\yii\BaseYii.php at line 383
378379380381382383384385386387388 if (!empty($config)) {
$args[] = $config;
}
return $reflection->newInstanceArgs($args);
} else {
return empty($config) ? new $class : new $class($config);
}
}
/**
* Logs a trace message.
2. in C:\xampp\htdocs\fems\views\product\_form.php – yii\widgets\ActiveForm::field() at line 17
1213141516171819202122
<div class="product-form">
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'ProductCode', ['class' => 'col-lg-3'])->textInput(['maxlength' => 100]) ?>
<?= $form->field($model, 'ProductDescription')->textInput(['maxlength' => 250]) ?>
<?= $form->field($model, 'ProductCategoryId')->textInput() ?>
i’m sure css class already in bootsrap.css
ferrylukito
(Ferrylukito2003)
December 9, 2013, 3:12am
2
i have wrong using parameter "options"
@param array $options the additional configurations for the field object
there is any way to add css class into label form ?
my purpose is make horizontal form
kartikv
December 18, 2013, 10:51am
4
i have wrong using parameter "options"
@param array $options the additional configurations for the field object
there is any way to add css class into label form ?
my purpose is make horizontal form
You can override the [font="Courier New"]template[/font] property of the [font="Courier New"]ActiveField[/font].
Alternatively, for horizontal & inline forms, you can do this much easier using my yii2-widgets extension. It covers most Twitter Bootstrap form features including input addons. For your horizontal form you can use something like.
<?php
use kartik\widgets\ActiveForm
$form = ActiveForm::begin([
'id' => 'login-form',
'type' => ActiveForm::TYPE_HORIZONTAL,
'formConfig' => ['labelSpan' => 3, 'deviceSize' => ActiveForm::SIZE_SMALL]
]);
?>
<?= $form->field($model, 'username') ?>
<?= $form->field($model, 'password')->passwordInput() ?>
<?= $form->field($model, 'rememberMe')->checkbox() ?>
<div class="form-group">
<div class="col-sm-offset-3 col-sm-9">
<?= Html::submitButton('Login', ['class' => 'btn btn-primary']) ?>
</div>
</div>
<?php ActiveForm::end(); ?>
flarpy
(Peter)
November 21, 2014, 4:02am
5
or if using Kartik ActiveField
<?= $form->field($model, 'minFrequency', ['addClass' => 'myclass'])->textInput() ?>