Skip to content

Commit

Permalink
Merge branch 'master' into 2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
joonsp committed Aug 20, 2012
2 parents d0691c5 + d05c573 commit 2d26bc8
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 12 deletions.
12 changes: 7 additions & 5 deletions Controller/SearchController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@ public function searchAction()

return $this->processForm($service->getSearchForm(), function($form) use($self, $service, $config) {
$data = $form->getData();


$limit = isset($config['default_limit']) ? $config['default_limit'] : null;

if($data->getSearchType() == 'search'){
$results = $service->search($data->getIndex(), $data->getTerm());
$results = $service->search($data->getIndex(), $data->getTerm(), $limit);
} elseif($data->getSearchType() == 'find') {
$results = $service->find($data->getIndex(), $data->getTerm());
}
$results = $service->find($data->getIndex(), $data->getTerm(), $limit);
}

$resultHtml = $self->renderView('XiSearchBundle:Search:search.html.twig', array(
'results' => $results, 'index' => $data->getIndex(), 'options' => json_decode($data->getOptions())
));
Expand Down
6 changes: 4 additions & 2 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@ public function getConfigTreeBuilder()
// Here you should define the parameters that are allowed to
// configure your bundle. See the documentation linked above for
// more information on that topic.

$rootNode
->children()
->variableNode('result_renderer_extensions')
->end()
->variableNode('default_limit')
->end()
->end();

return $treeBuilder;
}
}
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ XiSearchBundle:
prefix: /
```
### config.yml -file
```yml
xi_search:
result_renderer_extensions:
acmeType: acmeType_renderer_extension
default_limit: 50
```
### extend ajaxForm (from ajaxbundle) and make sure you bind your custom class as your ajax form handler (see ajaxbundle documentation)
``` coffee
Expand Down
6 changes: 4 additions & 2 deletions Resources/translations/messages.fi.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
search:
form:
term.label: Haku
term:
label: Haku
placeholder: Hakusana
submit_button: Hae
validation:
index.notblank: haku indeksi ei ole määritelty
search_type.notblank: haku tyyppi ei ole määritelty
term.notblank: hakuehto puuttuu
term.notblank: hakuehto puuttuu
3 changes: 2 additions & 1 deletion Resources/views/SearchForm/searchform.html.twig
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<form action="{{ path('XiSearchBundle_search') }}" class="ajax-form article-form" method="post" {{ form_enctype(form) }}>
{{ form_widget(form) }}
{{ form_widget(form.term, { 'attr': {'placeholder' : ('search.form.term.placeholder')|trans} }) }}
{{ form_rest(form) }}
<p>
<button type="submit">{{'search.form.submit_button'|trans}}</button>
</p>
Expand Down
4 changes: 2 additions & 2 deletions Resources/views/SearchForm/searchform_choosable.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
{{ form_widget(form.searchType) }}
{{ form_label(form.index) }}
{{ form_widget(form.index) }}
{{ form_widget(form.term) }}
{{ form_widget(form.term, { 'attr': {'placeholder' : ('search.form.term.placeholder')|trans} }) }}
{{ form_rest(form) }}

<div id="search-form">
<div id="xi_searchbundle_searchtype_submit">
<button type="submit">{{'search.form.submit_button'|trans}}</button>
</div>

Expand Down

0 comments on commit 2d26bc8

Please sign in to comment.