Hey guys i am trying to write simple search in database using Nette Framework, my Presenter (controller) looks like this:
<?php
public function searchsucceeded($searchword)
{
$selection = $this->database->findAll->select('*')->where("name LIKE ?", "%$searchword%");
return $selection;
}
protected function createComponentsearchForm()
{
$form = new Form;
$form->addText('name', 'Vyhladať ban, vložte nick zabanovaného hráča')
->setRequired('Vyhladať ban, vložte nick zabanovaného hráča');
$form->addSubmit('search', 'Hľadať')
->setAttribute('class', 'default')
->onSuccess[] = $this->searchsucceeded;
}
?>
To say true i am not even 100% sure that if its right, but it should be, what i need is to add it to let form use this function when i press SEARCH button and not to redirect to old search script.
My serach form:
<form action="index.php" method="POST">
<input type="text" style="margin-top:10px;" placeholder="Vyhľadať ban... (Zadajte nick hráča)" name="nickS" class="span10" required="required">
<input type="submit" value="Hľadať" name="sSubmit" class="btn btn-primary span2">
</form>
I am absolutly new in OOP and Nette as well so this question is prolly totaly noobish, i know how to simple do it without OOP but i prefer this option!
So is someone here who can help me?