Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fieldConfig => template doesn't works properly #186

Closed
FedericoBenedetti1976 opened this issue Oct 26, 2014 · 1 comment
Closed

fieldConfig => template doesn't works properly #186

FedericoBenedetti1976 opened this issue Oct 26, 2014 · 1 comment

Comments

@FedericoBenedetti1976
Copy link

Hi, i'm using FileInput widget on a form and i change
use yii\widgets\ActiveForm;
to
use kartik\widgets\ActiveForm;

I have two forms in this view, the second is:

$form_general = ActiveForm::begin([
'id' => 'profile-form',
'options' => ['class' => 'form-horizontal'],
'fieldConfig' => [
'template' => "{label}\n<div class="col-lg-7">{input}\n<div class="col-lg-7">{error}",
'labelOptions' => ['class' => 'col-lg-4 control-label'],
],
'enableAjaxValidation' => true,
]);

but using Kartik ActiveForm the 'template' setting doesn't works. If i rollback and use standard Yii ActiveForm, it's all ok (also Kartik FileInput).

Is there another way to set up 'template' options in Kartik ActiveForm?
Thank's

@kartik-v
Copy link
Owner

If you are using this ActiveForm/ActiveField widget you need to be aware of the bootstrap form layout style you are using (which is not included in the default yii activeform and activefield widgets).

What you are experiencing is because you are using HORIZONTAL FORM layout which requires special styling. The template can be set for other layouts (VERTICAL/INLINE). Its recommended you use the formConfig and fieldConfig properties in conjunction with other new properties for label, error etc. for defining your custom layouts.

The template was being overridden for horizontal forms - to preserve the special bootstrap styles and offsets.

However, I have now pushed a small enhancement now for you to define your own template, but beware it might break the horizontal form layout styling - you need to watch the HTML markup for bootstrap horizontal forms.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants