-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added new submit option to allow prevention of submit of field for PCI compliance by exclusion of the name attribute. Refactor to extend widgets from new InputWidget class
- Loading branch information
Andrew Blake
committed
Jun 28, 2016
1 parent
460b9c7
commit fac5907
Showing
13 changed files
with
217 additions
and
307 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
* @package andrewblake1\yii2-credit-card | ||
* @license https://github.com/andrewblake1/yii2-credit-card/blob/master/LICENSE.md MIT License | ||
* @link https://github.com/andrewblake1/yii2-credit-card | ||
* @version 1.1.0 | ||
* @version 1.1.1 | ||
*/ | ||
namespace andrewblake1\creditcard; | ||
|
||
|
@@ -18,109 +18,12 @@ | |
* | ||
* @author Andrew Blake <[email protected]> | ||
*/ | ||
class CreditCardCVCode extends \kartik\base\InputWidget | ||
class CreditCardCVCode extends InputWidget | ||
{ | ||
/** | ||
* @var string/boolean the addon content | ||
*/ | ||
public $addon = null; | ||
|
||
/** | ||
* @var array HTML attributes for the addon container | ||
* the following special options are identified | ||
* - asButton: boolean if the addon is to be displayed as a button. | ||
* - buttonOptions: array HTML attributes if the addon is to be | ||
* displayed like a button. If [[asButton]] is true, this will | ||
* default to ['class' => 'btn btn-default'] | ||
*/ | ||
public $addonOptions = []; | ||
|
||
/** | ||
* @var string use [[right]] or [[left]] type of addon | ||
* position near to input | ||
*/ | ||
public $addonPosition = 'right'; | ||
|
||
/** | ||
* @var array HTML attributes for the input group container | ||
*/ | ||
public $containerOptions = []; | ||
|
||
public $type = 'tel'; | ||
public $autocomplete = null; | ||
|
||
public function init() | ||
{ | ||
parent::init(); | ||
$this->_msgCat = 'creditcard'; | ||
$this->initI18N(__DIR__); | ||
|
||
$this->options['type'] = $this->type; | ||
$this->options['autocomplete'] = $this->autocomplete; | ||
|
||
$this->registerAssets(); | ||
} | ||
|
||
public function run() | ||
{ | ||
return Html::tag('div', $this->renderInput(), $this->containerOptions); | ||
} | ||
|
||
/** | ||
* This is largely copied from kartik\time\TimePicker | ||
* @return string | ||
*/ | ||
protected function renderInput() | ||
{ | ||
Html::addCssClass($this->options, 'form-control'); | ||
if (!empty($this->options['disabled'])) { | ||
Html::addCssClass($this->addonOptions, 'disabled-addon'); | ||
} | ||
if (ArrayHelper::getValue($this->pluginOptions, 'template', true) === false) { | ||
if (isset($this->size)) { | ||
Html::addCssClass($this->options, 'input-' . $this->size); | ||
Html::addCssClass($this->addonOptions, 'inline-addon inline-addon-' . $this->size); | ||
} else { | ||
Html::addCssClass($this->addonOptions, 'inline-addon'); | ||
} | ||
return $this->getInput('textInput') . Html::tag('span', $this->addon, $this->addonOptions); | ||
} | ||
Html::addCssClass($this->containerOptions, 'input-group'); | ||
$asButton = ArrayHelper::remove($this->addonOptions, 'asButton', false); | ||
$buttonOptions = ArrayHelper::remove($this->addonOptions, 'buttonOptions', []); | ||
if ($asButton) { | ||
Html::addCssClass($this->addonOptions, 'input-group-btn picker'); | ||
$buttonOptions['type'] = 'button'; | ||
if (empty($buttonOptions['class'])) { | ||
Html::addCssClass($buttonOptions, 'btn btn-default'); | ||
} | ||
$content = Html::button($this->addon, $buttonOptions); | ||
} else { | ||
Html::addCssClass($this->addonOptions, 'input-group-addon picker'); | ||
$content = $this->addon; | ||
} | ||
$addon = $this->addon | ||
? Html::tag('span', $content, $this->addonOptions) | ||
: null; | ||
if (isset($this->size)) { | ||
Html::addCssClass($this->containerOptions, 'input-group-' . $this->size); | ||
} | ||
switch($this->addonPosition) { | ||
default: | ||
case 'left': | ||
return $addon . $this->getInput('textInput'); | ||
break; | ||
|
||
case 'right': | ||
return $this->getInput('textInput') . $addon; | ||
break; | ||
} | ||
} | ||
|
||
public function registerAssets() | ||
{ | ||
$view = $this->getView(); | ||
CreditCardAsset::register($view); | ||
parent::registerAssets(); | ||
$this->registerPlugin('ccCVC'); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
* @package andrewblake1\yii2-credit-card | ||
* @license https://github.com/andrewblake1/yii2-credit-card/blob/master/LICENSE.md MIT License | ||
* @link https://github.com/andrewblake1/yii2-credit-card | ||
* @version 1.1.0 | ||
* @version 1.1.1 | ||
*/ | ||
namespace andrewblake1\creditcard; | ||
|
||
|
@@ -18,109 +18,13 @@ | |
* | ||
* @author Andrew Blake <[email protected]> | ||
*/ | ||
class CreditCardExpiry extends \kartik\base\InputWidget | ||
class CreditCardExpiry extends InputWidget | ||
{ | ||
/** | ||
* @var string/boolean the addon content | ||
*/ | ||
public $addon = false; | ||
|
||
/** | ||
* @var array HTML attributes for the addon container | ||
* the following special options are identified | ||
* - asButton: boolean if the addon is to be displayed as a button. | ||
* - buttonOptions: array HTML attributes if the addon is to be | ||
* displayed like a button. If [[asButton]] is true, this will | ||
* default to ['class' => 'btn btn-default'] | ||
*/ | ||
public $addonOptions = []; | ||
|
||
/** | ||
* @var string use [[right]] or [[left]] type of addon | ||
* position near to input | ||
*/ | ||
public $addonPosition = 'right'; | ||
|
||
/** | ||
* @var array HTML attributes for the input group container | ||
*/ | ||
public $containerOptions = []; | ||
|
||
public $type = 'tel'; | ||
public $autocomplete = 'cc-expiry'; | ||
|
||
public function init() | ||
{ | ||
parent::init(); | ||
$this->_msgCat = 'creditcard'; | ||
$this->initI18N(__DIR__); | ||
|
||
$this->options['type'] = $this->type; | ||
$this->options['autocomplete'] = $this->autocomplete; | ||
|
||
$this->registerAssets(); | ||
} | ||
|
||
public function run() | ||
{ | ||
return Html::tag('div', $this->renderInput(), $this->containerOptions); | ||
} | ||
|
||
/** | ||
* This is largely copied from kartik\time\TimePicker | ||
* @return string | ||
*/ | ||
protected function renderInput() | ||
{ | ||
Html::addCssClass($this->options, 'form-control'); | ||
if (!empty($this->options['disabled'])) { | ||
Html::addCssClass($this->addonOptions, 'disabled-addon'); | ||
} | ||
if (ArrayHelper::getValue($this->pluginOptions, 'template', true) === false) { | ||
if (isset($this->size)) { | ||
Html::addCssClass($this->options, 'input-' . $this->size); | ||
Html::addCssClass($this->addonOptions, 'inline-addon inline-addon-' . $this->size); | ||
} else { | ||
Html::addCssClass($this->addonOptions, 'inline-addon'); | ||
} | ||
return $this->getInput('textInput') . Html::tag('span', $this->addon, $this->addonOptions); | ||
} | ||
Html::addCssClass($this->containerOptions, 'input-group'); | ||
$asButton = ArrayHelper::remove($this->addonOptions, 'asButton', false); | ||
$buttonOptions = ArrayHelper::remove($this->addonOptions, 'buttonOptions', []); | ||
if ($asButton) { | ||
Html::addCssClass($this->addonOptions, 'input-group-btn picker'); | ||
$buttonOptions['type'] = 'button'; | ||
if (empty($buttonOptions['class'])) { | ||
Html::addCssClass($buttonOptions, 'btn btn-default'); | ||
} | ||
$content = Html::button($this->addon, $buttonOptions); | ||
} else { | ||
Html::addCssClass($this->addonOptions, 'input-group-addon picker'); | ||
$content = $this->addon; | ||
} | ||
$addon = $this->addon | ||
? Html::tag('span', $content, $this->addonOptions) | ||
: null; | ||
if (isset($this->size)) { | ||
Html::addCssClass($this->containerOptions, 'input-group-' . $this->size); | ||
} | ||
switch($this->addonPosition) { | ||
default: | ||
case 'left': | ||
return $addon . $this->getInput('textInput'); | ||
break; | ||
|
||
case 'right': | ||
return $this->getInput('textInput') . $addon; | ||
break; | ||
} | ||
} | ||
|
||
public function registerAssets() | ||
{ | ||
$view = $this->getView(); | ||
CreditCardAsset::register($view); | ||
parent::registerAssets(); | ||
$this->registerPlugin('ccExpiry'); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
* @package andrewblake1\yii2-credit-card | ||
* @license https://github.com/andrewblake1/yii2-credit-card/blob/master/LICENSE.md MIT License | ||
* @link https://github.com/andrewblake1/yii2-credit-card | ||
* @version 1.1.0 | ||
* @version 1.1.1 | ||
*/ | ||
namespace andrewblake1\creditcard; | ||
|
||
|
@@ -18,109 +18,16 @@ | |
* | ||
* @author Andrew Blake <[email protected]> | ||
*/ | ||
class CreditCardNumber extends \kartik\base\InputWidget | ||
class CreditCardNumber extends InputWidget | ||
{ | ||
/** | ||
* @var string/boolean the addon content | ||
*/ | ||
public $addon = '<i class="fa fa-lg fa-credit-card"></i>'; | ||
|
||
/** | ||
* @var array HTML attributes for the addon container | ||
* the following special options are identified | ||
* - asButton: boolean if the addon is to be displayed as a button. | ||
* - buttonOptions: array HTML attributes if the addon is to be | ||
* displayed like a button. If [[asButton]] is true, this will | ||
* default to ['class' => 'btn btn-default'] | ||
*/ | ||
public $addonOptions = []; | ||
|
||
/** | ||
* @var string use [[right]] or [[left]] type of addon | ||
* position near to input | ||
*/ | ||
public $addonPosition = 'right'; | ||
|
||
/** | ||
* @var array HTML attributes for the input group container | ||
*/ | ||
public $containerOptions = []; | ||
public $addon = '<i class="fa fa-lg fa-credit-card"></i>'; | ||
|
||
public $type = 'tel'; | ||
public $autocomplete = 'cc-number'; | ||
|
||
public function init() | ||
{ | ||
parent::init(); | ||
$this->_msgCat = 'creditcard'; | ||
$this->initI18N(__DIR__); | ||
|
||
$this->options['type'] = $this->type; | ||
$this->options['autocomplete'] = $this->autocomplete; | ||
|
||
$this->registerAssets(); | ||
} | ||
|
||
public function run() | ||
{ | ||
return Html::tag('div', $this->renderInput(), $this->containerOptions); | ||
} | ||
|
||
/** | ||
* This is largely copied from kartik\time\TimePicker | ||
* @return string | ||
*/ | ||
protected function renderInput() | ||
{ | ||
Html::addCssClass($this->options, 'form-control'); | ||
if (!empty($this->options['disabled'])) { | ||
Html::addCssClass($this->addonOptions, 'disabled-addon'); | ||
} | ||
if (ArrayHelper::getValue($this->pluginOptions, 'template', true) === false) { | ||
if (isset($this->size)) { | ||
Html::addCssClass($this->options, 'input-' . $this->size); | ||
Html::addCssClass($this->addonOptions, 'inline-addon inline-addon-' . $this->size); | ||
} else { | ||
Html::addCssClass($this->addonOptions, 'inline-addon'); | ||
} | ||
return $this->getInput('textInput') . Html::tag('span', $this->addon, $this->addonOptions); | ||
} | ||
Html::addCssClass($this->containerOptions, 'input-group'); | ||
$asButton = ArrayHelper::remove($this->addonOptions, 'asButton', false); | ||
$buttonOptions = ArrayHelper::remove($this->addonOptions, 'buttonOptions', []); | ||
if ($asButton) { | ||
Html::addCssClass($this->addonOptions, 'input-group-btn picker'); | ||
$buttonOptions['type'] = 'button'; | ||
if (empty($buttonOptions['class'])) { | ||
Html::addCssClass($buttonOptions, 'btn btn-default'); | ||
} | ||
$content = Html::button($this->addon, $buttonOptions); | ||
} else { | ||
Html::addCssClass($this->addonOptions, 'input-group-addon picker'); | ||
$content = $this->addon; | ||
} | ||
$addon = $this->addon | ||
? Html::tag('span', $content, $this->addonOptions) | ||
: null; | ||
if (isset($this->size)) { | ||
Html::addCssClass($this->containerOptions, 'input-group-' . $this->size); | ||
} | ||
switch($this->addonPosition) { | ||
default: | ||
case 'left': | ||
return $addon . $this->getInput('textInput'); | ||
break; | ||
|
||
case 'right': | ||
return $this->getInput('textInput') . $addon; | ||
break; | ||
} | ||
} | ||
|
||
public function registerAssets() | ||
{ | ||
$view = $this->getView(); | ||
CreditCardAsset::register($view); | ||
parent::registerAssets(); | ||
$this->registerPlugin('ccNumber'); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.