Hello,
I'm trying to understand how to display search results. I'm basically allowing the user to enter name of a player and then we will display information about that player.
Here is what I have:
private static $allowed_actions = array('ADLResultForm');
public function ADLResultForm() {
$fields = new FieldList (
new TextField('Summoner')
);
$actions = new FieldList(
new FormAction('seekPlayer', 'Search')
);
$form = new Form($this, 'ADLResultForm', $fields, $actions, $requiredFields);
$requiredFields = new RequiredFields(array('Summoner'));
$form->Fields()->dataFieldByName('Summoner')->addExtraClass('Summoner');
return $form;
}
function seekPlayer($data, $form, $request) {
if(checkBadCharacters($data)){
$summoners = ADLPlayer::get()->filter('SummonerTag', $data['Summoner']);
$total = $summoners->Count();
$list = new ArrayList();
foreach($summoners as $summoner){
$list-push(new ArrayData(array(
'SummonerTag' => $summoner->SummonerTag,
'Rating'=> $summoner->Rating,
'MVPCount'=> $summoner->MVPCount,
'GamesWon'=> $summoner->GamesWon,
'GamesLost'=> $summoner->GamesLost,
'LastPlayed'=> $summoner->LastPlayed
)));
}
return $list;
}
}
I'm not fully understanding how this works. How do I grab the search results and throw them back to my page to be displayed, I don't understand how to pass the data without having to use sessions.