Skip to content

Commit

Permalink
Add option for how to handle null values on boolean conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
joni1993 committed Oct 21, 2019
1 parent d497b5f commit da8d6f0
Showing 1 changed file with 15 additions and 1 deletion.
Expand Up @@ -26,6 +26,20 @@ public function getName()

public static function addSettingsFormFields(QuickForm $form)
{
$form->addElement('select', 'null_values', array(
'label' => 'Null values',
'required' => true,
'description' => $form->translate(
'Your import source may contain null values. You can specifiy'
. ' here wether your want to keep them or treat them as invalid'
),
'value' => 'keep',
'multiOptions' => $form->optionalEnum(array(
'keep' => $form->translate('Keep'),
'invalid' => $form->translate('Are invalid'),
)),
));

$form->addElement('select', 'on_invalid', array(
'label' => 'Invalid properties',
'required' => true,
Expand All @@ -49,7 +63,7 @@ public static function addSettingsFormFields(QuickForm $form)

public function transform($value)
{
if ($value === false || $value === true) {
if ($value === false || $value === true || ($value === null && $this->getSetting('null_values') == 'keep')) {
return $value;
}

Expand Down

0 comments on commit da8d6f0

Please sign in to comment.