Skip to content

Commit 813a066

Browse files
committed
Update hint styling & code for old PHP ver fix #130 fix #131
1 parent 64b83af commit 813a066

File tree

5 files changed

+15
-12
lines changed

5 files changed

+15
-12
lines changed

CHANGE.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ Change Log: `yii2-widget-activeform`
55

66
**Date**: _under development_
77

8+
- (enh #131): Enhance hint block styling.
9+
- (enh #130): Support isset validation for older PHP versions.
810
- (enh #129): Enhance radioList and checkboxList styles.
911

1012
## Version 1.6.0

src/ActiveField.php

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ protected function createLayoutConfig($instanceConfig = [])
493493
$layout = $form->type;
494494
$bsVer = $form->getBsVer();
495495
$config = [
496-
'hintOptions' => ['tag' => 'div', 'class' => ['form-text', 'text-muted', 'small']],
496+
'hintOptions' => ['tag' => 'div', 'class' => ['hint-block']],
497497
'errorOptions' => ['tag' => 'div', 'class' => 'invalid-feedback'],
498498
'inputOptions' => ['class' => 'form-control'],
499499
'labelOptions' => ['class' => ['form-label']],
@@ -502,11 +502,7 @@ protected function createLayoutConfig($instanceConfig = [])
502502
if ($bsVer === 4) {
503503
$config['labelOptions'] = ['class' => []];
504504
} elseif ($bsVer === 3) {
505-
$config = [
506-
'hintOptions' => ['tag' => 'p', 'class' => ['help-block']],
507-
'errorOptions' => ['tag' => 'p', 'class' => 'help-block help-block-error'],
508-
'inputOptions' => ['class' => 'form-control'],
509-
];
505+
$config['errorOptions'] = ['tag' => 'div', 'class' => 'help-block help-block-error'];
510506
}
511507
if ($layout === ActiveForm::TYPE_HORIZONTAL) {
512508
$config['template'] = "{label}\n{beginWrapper}\n{input}\n{error}\n{hint}\n{endWrapper}";
@@ -662,13 +658,11 @@ public function hint($content, $options = [])
662658
{
663659
if ($this->getConfigParam('showHints') === false) {
664660
$this->parts['{hint}'] = '';
665-
666661
return $this;
667662
}
668663
if ($this->_isHintSpecial) {
669664
Html::addCssClass($options, 'kv-hint-block');
670665
}
671-
672666
return parent::hint($this->generateHint($content), $options);
673667
}
674668

@@ -946,7 +940,7 @@ public function widget($class, $config = [])
946940
*/
947941
public function staticInput($options = [])
948942
{
949-
$content = $this->staticValue ?? Html::getAttributeValue($this->model, $this->attribute);
943+
$content = isset($this->staticValue) ? $this->staticValue : Html::getAttributeValue($this->model, $this->attribute);
950944
$this->form->addCssClass($options, ActiveForm::BS_FORM_CONTROL_STATIC);
951945
$this->parts['{input}'] = Html::tag('div', $content, $options);
952946
$this->_isStatic = true;
@@ -1188,7 +1182,7 @@ protected function initDisability(&$options)
11881182
*/
11891183
protected function getConfigParam($param, $default = true)
11901184
{
1191-
return $this->$param ?? ArrayHelper::getValue($this->form->formConfig, $param, $default);
1185+
return isset($this->$param) ? $this->$param : ArrayHelper::getValue($this->form->formConfig, $param, $default);
11921186
}
11931187

11941188
/**

src/ActiveForm.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,12 +300,14 @@ protected function initForm()
300300
if ($this->isHorizontal()) {
301301
$css[] = 'kv-form-horizontal';
302302
}
303+
$formCss = 'kv-form-bs3';
303304
if ($bsVer !== 3) {
304-
$css[] = 'kv-form-bs4';
305+
$formCss = 'kv-form-bs4';
305306
if ($this->tooltipStyleFeedback) {
306307
$css[] = 'tooltip-feedback';
307308
}
308309
}
310+
$css[] = $formCss;
309311
Html::addCssClass($this->options, $css);
310312
}
311313

src/assets/css/activeform.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,11 @@ label.disabled, label.readonly, .disabled label, .readonly label {
204204
.kv-form-bs4 .has-error .invalid-feedback {
205205
display: block;
206206
}
207+
.kv-form-bs3 .hint-block {
208+
font-size: 12px;
209+
margin-top: -5px;
210+
color: #999;
211+
}
207212
.kv-form-bs4 .hint-block {
208213
font-size: 0.75rem;
209214
margin-top: 0.375rem;

src/assets/css/activeform.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)