kartik-v / yii2-widget-activeform

Enhanced Yii2 active-form and active-field with full bootstrap styling support (sub repo split from yii2-widgets).
http://demos.krajee.com/widget-details/active-form
Other
64 stars 35 forks source link

Enh: Add 'inputSpan' integer option to ActiveField #16

Closed nbogol closed 9 years ago

nbogol commented 9 years ago

Enhancement. Add 'inputSpan' integer option to the kartik\form\ActiveField. If set, this option will result 'col--' class set for input div wrapper.

kartik-v commented 9 years ago

Some questions (thanks for the PR though)... as this PR may break the layout for some scenarios

IMO... the PR can be simplified to just one option to capture the input container and its HTML attributes.

nbogol commented 9 years ago

Kartik, I did some more testing and code inspection: My code is in effect only when '$form->hasInputCss()' is true. And, if you do not explicitly set formConfig.labelSpan, it is true only for HORIZONTAL type of the form and my code is executed and works just fine. But if you set formConfig.labelSpan, it will be executed for INLINE and VERTICAL. I think formConfig.labelSpan should be disabled for INLINE and VERTICAL form types, because it does not make sense and does not work correctly anyway. (try to set formConfig.labelSpan=2 for VERTICAL form - it will render as horizontal)

nbogol commented 9 years ago

Kartik, do you have any comments on my response or you do not want to do this. Please let me know. I will remove my pull request then.

kartik-v commented 9 years ago

Not yet checked on this yet. But on initial thoughts since this is only for horizontal forms - the inputSpan is automatically derived based on labelSpan for horizontal forms. Is there a reason why you do not want to provide labelSpan?

nbogol commented 9 years ago

For VERTICAL form type labelSpan is irrelevant, right? :

Name [ ]

kartik-v commented 9 years ago

Yes my query was more for horizontal forms - where input span is derived automatically based on label span. Do you wish to override the input span with this use case? Once you confirm will check a bit on this later to see.

kartik-v commented 9 years ago

I think the use case for where this is useful is for HORIZONTAL forms when you wish to hide the label. Right? Will check and incorporate this.

kartik-v commented 9 years ago

Ok enhancements have been done and you have two options:

// Address and city side by side for horizontal
echo $form->field($model, 'address', [
    'contentBeforeInput' =>  '<div class="row"><div class="col-sm-6">',
    'contentAfterInput' =>  '</div><div class="col-sm-6">' .
        $form->field($model, 'city')->label(false) . '</div></div>'
]);