Skip to content

Commit

Permalink
Update to release v1.5.7
Browse files Browse the repository at this point in the history
  • Loading branch information
kartik-v committed Sep 27, 2018
1 parent 7420497 commit 6bc8bc7
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 26 deletions.
6 changes: 6 additions & 0 deletions CHANGE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Change Log: `yii2-widget-activeform`
====================================

## Version 1.5.7

**Date**: 27-Sep-2018

- (enh #115): Enhance rendering of Bootstrap 4.x custom file control.

## Version 1.5.6

**Date**: 27-Sep-2018
Expand Down
36 changes: 16 additions & 20 deletions src/ActiveField.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @copyright Copyright © Kartik Visweswaran, Krajee.com, 2015 - 2018
* @package yii2-widgets
* @subpackage yii2-widget-activeform
* @version 1.5.6
* @version 1.5.7
*/

namespace kartik\form;
Expand Down Expand Up @@ -247,6 +247,12 @@ class ActiveField extends YiiActiveField
*/
public $contentAfterHint = '';

/**
* @var string the template for rendering the Bootstrap 4.x custom file browser control
* @see https://getbootstrap.com/docs/4.1/components/forms/#file-browser
*/
public $customFileTemplate = "<div class=\"custom-file\">\n{input}\n{label}\n</div>\n{error}\n{hint}";

/**
* @var string the template for rendering checkboxes and radios for a default Bootstrap markup without an enclosed
* label
Expand Down Expand Up @@ -538,8 +544,7 @@ public function checkboxList($items, $options = [])
public function dropDownList($items, $options = [])
{
$this->initDisability($options);
$custom = $this->isCustomControl($options);
Html::addCssClass($options, $custom ? 'custom-select' : $this->addClass);
Html::addCssClass($options, $this->isCustomControl($options) ? 'custom-select' : $this->addClass);
return parent::dropDownList($items, $options);
}

Expand Down Expand Up @@ -575,20 +580,13 @@ protected function isCustomControl(&$options)
*/
public function fileInput($options = [])
{
$custom = $this->isCustomControl($options);
if (!$custom) {
return parent::fileInput($options);
if ($this->isCustomControl($options)) {
Html::removeCssClass($options, 'form-control');
Html::addCssClass($options, 'custom-file-input');
Html::addCssClass($this->labelOptions, 'custom-file-label');
$this->template = $this->customFileTemplate;
}
Html::removeCssClass($options, 'form-control');
Html::addCssClass($options, 'custom-file-input');
Html::addCssClass($this->labelOptions, 'custom-file-label');
$this->template = "{beginWrapper}\n{input}\n{hint}\n{error}\n{endWrapper}";
parent::fileInput($options);
$this->label();
$parts = $this->parts['{input}'] . $this->parts['{label}'];
$this->parts['{input}'] = Html::tag('div', $parts, ['class' => 'custom-file']);
$this->parts['{label}'] = '';
return $this;
return parent::fileInput($options);
}

/**
Expand All @@ -598,8 +596,7 @@ public function fileInput($options = [])
public function input($type, $options = [])
{
$this->initFieldOptions($options);
$custom = $this->isCustomControl($options);
if ($custom && $type === 'range') {
if ($this->isCustomControl($options) && $type === 'range') {
Html::addCssClass($options, 'custom-range');
}
if ($type !== 'range' && $type !== 'color') {
Expand Down Expand Up @@ -649,8 +646,7 @@ public function label($label = null, $options = [])
public function listBox($items, $options = [])
{
$this->initDisability($options);
$custom = $this->isCustomControl($options);
Html::addCssClass($options, $custom ? 'custom-select' : $this->addClass);
Html::addCssClass($options, $this->isCustomControl($options) ? 'custom-select' : $this->addClass);
return parent::listBox($items, $options);
}

Expand Down
2 changes: 1 addition & 1 deletion src/ActiveForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2015 - 2018
* @package yii2-widgets
* @subpackage yii2-widget-activeform
* @version 1.5.6
* @version 1.5.7
*/

namespace kartik\form;
Expand Down
2 changes: 1 addition & 1 deletion src/ActiveFormAsset.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2015 - 2018
* @package yii2-widgets
* @subpackage yii2-widget-activeform
* @version 1.5.6
* @version 1.5.7
*/

namespace kartik\form;
Expand Down
2 changes: 1 addition & 1 deletion src/assets/css/activeform.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2015 - 2018
* @package yii2-widgets
* @subpackage yii2-widget-activeform
* @version 1.5.6
* @version 1.5.7
*
* Active Form Styling for Bootstrap 3.x & Bootstrap 4.x
* Built for Yii Framework 2.0
Expand Down
2 changes: 1 addition & 1 deletion src/assets/css/activeform.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/assets/js/activeform.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @package yii2-widget-activeform
* @author Kartik Visweswaran <[email protected]>
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2015 - 2018
* @version 1.5.6
* @version 1.5.7
*
* Active Field Hints Display Module
*
Expand Down
2 changes: 1 addition & 1 deletion src/assets/js/activeform.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6bc8bc7

Please sign in to comment.