Skip to content

Commit

Permalink
Merge pull request #1787 from jaanusnurmoja/patch-56
Browse files Browse the repository at this point in the history
fix: empty birthday was forced to save zero date
  • Loading branch information
cheesegrits committed Mar 28, 2017
2 parents 7587c8b + 918f981 commit e7b3368
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions plugins/fabrik_element/birthday/birthday.php
Expand Up @@ -302,7 +302,7 @@ private function _dayOptions()
FText::_($params->get('birthday_daylabel', 'PLG_ELEMENT_BIRTHDAY_DAY')),
'value',
'text',
true
false
)
);

Expand All @@ -329,7 +329,7 @@ private function _monthOptions()
FText::_($params->get('birthday_monthlabel', 'PLG_ELEMENT_BIRTHDAY_MONTH')),
'value',
'text',
true
false
)
);
$monthLabels = $this->_monthLabels();
Expand Down Expand Up @@ -357,7 +357,7 @@ private function _yearOptions()
FText::_($params->get('birthday_yearlabel', 'PLG_ELEMENT_BIRTHDAY_YEAR')),
'value',
'text',
true
false
)
);
// Jaanus: now we can choose one exact year A.C to begin the dropdown AND would the latest year be current year or some years earlier/later.
Expand Down Expand Up @@ -400,9 +400,11 @@ public function storeDatabaseFormat($val, $data)
* @TODO: if NULL value is the first in repeated group then in list view whole group is empty.
* Could anyone find a solution? I give up :-(
* Paul 20130904 I fixed the id fields and I am getting a string passed in as $val here yyyy-m-d.
* Jaanus: saved data could be date or nothing (null). Previous return '' wrote always '0000-00-00' as DATE field doesn't know ''.
* such value as '' and therefore setting element to save null hadn't expected impact. Simple return; returns null as it should.
*
*
* @return string yyyy-mm-dd
* @return string yyyy-mm-dd or null or 0000-00-00 if needed and set
*/

private function _indStoreDBFormat($val)
Expand All @@ -424,7 +426,7 @@ private function _indStoreDBFormat($val)
}
}

return '';
return;
}

/**
Expand Down Expand Up @@ -869,10 +871,6 @@ public function getFilterQuery($key, $condition, $value, $originalValue, $type =
case 'laterthisyear':
throw new UnexpectedValueException('The birthday element can not deal with "Later This Year" prefilters');
break;
case 'thisyear':
$search = array(date('Y'), '', '');
return $this->_dayMonthYearFilterQuery($key, $search);
break;
case 'today':
$search = array(date('Y'), date('n'), date('j'));
return $this->_dayMonthYearFilterQuery($key, $search);
Expand Down

0 comments on commit e7b3368

Please sign in to comment.