I've got two fields in custom form which work as dropdown : Birth and death date
My code is:
class Senator extends DataObject
{
static $db = array (
'BirthYear' => 'Int',
'DEathYear' => 'Int',
....
)
}
and
public function getCustomSearchContext() {
{
static $db = array (
$fields->push(new DropdownField('BirthYear', 'Birth Year', Dataobject::get("Senator","","BirthYear ASC")->map("BirthYear", "BirthYear")));
$fields->push(new DropdownField('DeathYear', 'Death Year', Dataobject::get("Senator","","DeathYear ASC")->map("DeathYear", "DeathYear", "Please Select")));
....
)
}
I'm looking for solution for two my problems:
1. I've got a lot of duplicates in years. I'm removing it jquery now, but it would be great to get it propertlly from system
2. How can I make third field with how old was each person? DeathYear - BirthYear ? I tried several ways but I have: Fatal error: Call to a member function setValue() on a non-object in /framework/search/filters/SearchFilter.php on line 194 always.
Anyone can help?