Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: empty birthday was forced to save zero date #1787

Merged
merged 9 commits into from
Mar 28, 2017
16 changes: 7 additions & 9 deletions plugins/fabrik_element/birthday/birthday.php
Original file line number Diff line number Diff line change
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