Hey there,
I'm trying to create a dropdown form field, but would like to retrieve the available options from the database with only the available occurences. Normally i would use distinct in my query, but now i would like to use the dataobject to retrieve the data on a nice way.
Is this possible?
Now i've got it like this:
$spec = DataObject::get("VacaturePage", "", "", "", "")->column('Branche');
print_r(array_unique($spec));
but there should be a nicer way i think.
tnx in advance!
now i've got it like this :
$aType = array(0 => 'All types');
$aType = ArrayLib::cleanArray(ArrayLib::associative_push($aType,ArrayLib::valuekey(array_values(array_unique(DataObject::get("VacaturePage")->column('Type_vacature'))))));
$searchType = new DropdownField('type','',$aType);
I added 2 functions to the ArrayLib
cleanArray to clean out empty values in the array and associative_push so i can use a default value.
It may be nice for the distribution ;)