-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
allow user to choose which index to search from
- Loading branch information
Showing
5 changed files
with
141 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
namespace Xi\Bundle\SearchBundle\Form; | ||
|
||
use Symfony\Component\Form\AbstractType; | ||
use Symfony\Component\Form\FormBuilder; | ||
use Symfony\Component\OptionsResolver\OptionsResolverInterface; | ||
|
||
class ChoosableSearchType extends SearchType | ||
{ | ||
|
||
private $choices = array(); | ||
|
||
public function __construct($choices) | ||
{ | ||
$this->choices = $choices; | ||
} | ||
|
||
public function buildForm(FormBuilder $builder, array $options) | ||
{ | ||
$builder | ||
->add('options', 'hidden') | ||
->add('index', 'choice', array('choices' => $this->choices, 'expanded' => true, 'label' => 'xi_search.choose-index')) | ||
->add('searchType', 'hidden') | ||
->add('term', 'text', array('label' => 'search.form.term.label')); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<form action="{{ path('XiSearchBundle_search') }}" class="ajax-form search-form" method="post" {{ form_enctype(form) }}> | ||
{{ form_widget(form.options) }} | ||
{{ form_widget(form.searchType) }} | ||
{{ form_label(form.index) }} | ||
{{ form_widget(form.index) }} | ||
{{ form_widget(form.term) }} | ||
{{ form_rest(form) }} | ||
|
||
<div id="search-form"> | ||
<button type="submit">{{'search.form.submit_button'|trans}}</button> | ||
</div> | ||
|
||
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters