Got it.
I have used smindel's DataObejctPicker field with some interface modifications to make it a bit smoother: https://github.com/mateusz/silverstripe-dataobjectpicker/ . This field allows user to type a keyword, and provides suggestions which can be chosen. They populate an invisible field which can then be submitted normally to form handler.
$picker = new DataObjectPicker('PrWrapperID', 'P&R Wrapper');
$picker->setConfig('completeFunction', array('PrWrapper', 'pickerSuggestion'));
The callback accepts a SS_HTTPRequest, and returns an json array of arrays with line items.
static function pickerSuggestion($req) {
$request = Convert::raw2sql($req->requestVar('request'));
$results = DataObject::get('PrWrapper', "\"Title\" ILIKE '%$request%' OR \"Summary\" ILIKE '%$request%'", "\"ReleaseDate\" DESC");
$json = array(
array(
'id' => '0',
'title' => '-- none selected --',
'full' => "-- select none --",
'style' => 'color:red',
),
);
if ($results) {
foreach ($results as $result) {
$json[] = array(
'id' => $result->ID,
'title' => Convert::raw2att($result->obj('Title')->LimitCharacters(30)),
'full' => Convert::raw2att("$result->Title [".$result->Type()->Name."]")
);
}
}
return json_encode($json);
}
Thanks!
Mateusz