Skip to content

Commit

Permalink
[7-4] お問い合わせ一覧のテンプレート修正
Browse files Browse the repository at this point in the history
  • Loading branch information
hidenorigoto committed Dec 28, 2015
1 parent 61e74b2 commit c78a42c
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 2 deletions.
20 changes: 18 additions & 2 deletions app/Resources/views/Admin/Inquiry/index.html.twig
Expand Up @@ -6,11 +6,13 @@
<h2 class="sub-header">お問い合わせ管理</h2>

<div>
{{ form_start(form, {'attr': {'novalidate': 'novalidate'}}) }}
{{ form_start(form, {'attr': {'id':'searchForm', 'novalidate': 'novalidate'}}) }}
検索:{{ form_widget(form.search) }}

{{ form_widget(form.submit, {"attr": {"class":"btn btn-default"}}) }}
{{ form_widget(form.submit, {"attr": {"class":"btn btn-default searchButton"}}) }}
{{ form_end(form) }}

<a class="btn btn-default downloadButton">CSVダウンロード</a>
</div>

<table class="table table-striped">
Expand Down Expand Up @@ -38,3 +40,17 @@
</tbody>
</table>
{% endblock %}

{% block javascripts %}
{{ parent() }}
<script type="text/javascript">
$('.downloadButton').click(function() {
$('#searchForm').attr('action', '{{ path("app_admininquirylist_index", {"_format":"csv"}) }}');
$('#searchForm').submit();
});
$('.searchButton').click(function() {
$('#searchForm').attr('action', '{{ path("app_admininquirylist_index", {"_format":"html"}) }}');
$('#searchForm').submit();
});
</script>
{% endblock %}
25 changes: 25 additions & 0 deletions docs/lists/ch07/07-04.txt
@@ -0,0 +1,25 @@
<div>
{{ form_start(form, {'attr': {'id':'searchForm', 'novalidate': 'novalidate'}}) }}
検索:{{ form_widget(form.search) }}

{{ form_widget(form.submit, {"attr": {"class":"btn btn-default searchButton"}}) }}
{{ form_end(form) }}

<a class="btn btn-default downloadButton">CSVダウンロード</a>
</div>

...

{% block javascripts %}
{{ parent() }}
<script type="text/javascript">
$('.downloadButton').click(function() {
$('#searchForm').attr('action', '{{ path("app_admininquirylist_index", {"_format":"csv"}) }}');
$('#searchForm').submit();
});
$('.searchButton').click(function() {
$('#searchForm').attr('action', '{{ path("app_admininquirylist_index", {"_format":"html"}) }}');
$('#searchForm').submit();
});
</script>
{% endblock %}

0 comments on commit c78a42c

Please sign in to comment.