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
Option "formConfig" can't be changed dynamically #76
Comments
Form config is set at ActiveForm initialization in the In my opinion you must use FormGrid builder for such variation scenarios. |
Am open for an enhancement. You can submit your ideas or share a PR as well. Let know. |
Hi Kartik Short explanation: I moved the initialization of labelCss, inputCss and offsetCss (getFormLayoutStyle) from ActiveForm to ActiveField because CSS of a field is a property of a field and not a form. The form config can be a frame which inherits a standard setting. Now the definition of 'labelSpan' and 'deviceSize' is settable in fieldConfig and 'formConfig'. Plus 'formConfig' can be changed between 'ActiveForm::begin' and 'ActiveForm::end. This gives the possibility to use the setting for a group of fields. For an individual field the call is: <?= $form->field($model, 'attributeName', ['labelSpan' => 2, 'deviceSize' => 'sm']) Further I have compared your widgets with 'yii/bootstrap/ActiveForm' resp. 'ActiveField'. Your widget has more functionalities and it's much better. The only advantage of them is the enhanced template with label- and input wrappers plus the option of 'horizontalCssClasses' which gives a complete control for individual grid classes. Example 'col-sm-3 hidden-xs'. see http://www.yiiframework.com/doc-2.0/yii-bootstrap-activeform.html and http://www.yiiframework.com/doc-2.0/yii-bootstrap-activefield.html |
Sure you can go ahead with the enh. I have some thoughts on where it may break a few functionality. Will update on how to overcome those. |
Some feedback:
I suppose you have mentioned on the same lines (but just wished to add few cents). Also when you have a code, I can update over that. |
…h Yii/bootstrap/ActiveForm and ActiveField.
During init of activeForm 'formConfig' is read and CSS are calculated once. LabelSpan and Size is stored in private variables like _labelCss or _inputCss. ActiveField reads this values during layout built.
In my form I have smaller and larger fields and sometimes two or one in a single row. I looked for a possibility to override the labelSpan value. As I didn't find an option to change the labelSpan value by calling the field method. So I had the idea to change value in 'formConfig' like
then call the $form->field method and change 'formConfig' back. Unfortunately there is no change.
Methods like activeForm->getInputCss() should recreate the CSS part on the fly by using getFormLayoutStyle() instead of reading a private variable.
Or do you see another possibility?
Thank you.
The text was updated successfully, but these errors were encountered: