add new post form in material header

This commit is contained in:
Nicolas Lœuillet 2015-08-12 08:22:30 +02:00 committed by Nicolas Lœuillet
parent fedaf00537
commit 053b9568b2
10 changed files with 66 additions and 52 deletions

View File

@ -15,11 +15,11 @@ class EntryController extends Controller
/**
* @param Request $request
*
* @Route("/new", name="new_entry")
* @Route("/new-entry", name="new_entry")
*
* @return \Symfony\Component\HttpFoundation\Response
*/
public function addEntryAction(Request $request)
public function addEntryFormAction(Request $request)
{
$entry = new Entry($this->getUser());
@ -45,11 +45,23 @@ class EntryController extends Controller
return $this->redirect($this->generateUrl('homepage'));
}
return $this->render('WallabagCoreBundle:Entry:new.html.twig', array(
return $this->render('WallabagCoreBundle:Entry:new_form.html.twig', array(
'form' => $form->createView(),
));
}
/**
* @param Request $request
*
* @Route("/new", name="new")
*
* @return \Symfony\Component\HttpFoundation\Response
*/
public function addEntryAction(Request $request)
{
return $this->render('WallabagCoreBundle:Entry:new.html.twig');
}
/**
* Edit an entry content.
*

View File

@ -3,5 +3,5 @@
{% block title %}{% trans %}Save new entry{% endtrans %}{% endblock %}
{% block content %}
{{ form(form) }}
{{ render(controller( "WallabagCoreBundle:Entry:addEntryForm" )) }}
{% endblock %}

View File

@ -0,0 +1,15 @@
<form name="entry" method="post" action="{{ path('new_entry')}}">
{% if form_errors(form) %}
<span class="black-text">{{ form_errors(form) }}</span>
{% endif %}
{% if form_errors(form.url) %}
<span class="black-text">{{ form_errors(form.url) }}</span>
{% endif %}
{{ form_label(form.url) }}
{{ form_widget(form.url) }}
<div class="hidden">{{ form_rest(form) }}</div>
</form>

View File

@ -7,7 +7,7 @@
<p>{% trans %}There are several ways to save an article:{% endtrans %}</p>
<ul>
<li><a href="{{ path('new_entry') }}">{% trans %}Thanks to this form{% endtrans %}</a></li>
<li><a href="{{ path('new') }}">{% trans %}Thanks to this form{% endtrans %}</a></li>
</ul>
<h3>{% trans %}Browser Addons{% endtrans %}</h3>
<ul>

View File

@ -72,7 +72,7 @@
<li><a href="{{ path('starred') }}">{% trans %}favorites{% endtrans %}</a></li>
<li><a href="{{ path('archive') }}"}>{% trans %}archive{% endtrans %}</a></li>
<li><a href="{{ path ('tag') }}">{% trans %}tags{% endtrans %}</a></li>
<li><a href="{{ path('new_entry') }}">{% trans %}save a link{% endtrans %}</a></li>
<li><a href="{{ path('new') }}">{% trans %}save a link{% endtrans %}</a></li>
<li style="position: relative;"><a href="javascript: void(null);" id="search">{% trans %}search{% endtrans %}</a>
<div id="search-form" class="messages info popup-form">
<form method="get" action="index.php">

View File

@ -3,38 +3,5 @@
{% block title %}{% trans %}Save new entry{% endtrans %}{% endblock %}
{% block content %}
<div class="row">
<div class="col s12">
<div class="card-panel">
<form name="entry" method="post" action="">
<div class="card-content">
{% if form_errors(form) %}
<span class="black-text">{{ form_errors(form) }}</span>
{% endif %}
{% if form_errors(form.url) %}
<span class="black-text">{{ form_errors(form.url) }}</span>
{% endif %}
<div class="input-field s12">
{{ form_label(form.url) }}
{{ form_widget(form.url) }}
</div>
<button class="btn waves-effect waves-light" type="submit" name="entry[save]">
{% trans %}Save{% endtrans %}
<i class="mdi-content-send right"></i>
</button>
</div>
<div class="hidden">{{ form_rest(form) }}</div>
</form>
{{ form(form) }}
</div>
</div>
</div>
{{ render(controller( "WallabagCoreBundle:Entry:addEntryForm" )) }}
{% endblock %}

View File

@ -0,0 +1,14 @@
<form name="entry" method="post" action="{{ path('new_entry')}}">
{% if form_errors(form) %}
<span class="black-text">{{ form_errors(form) }}</span>
{% endif %}
{% if form_errors(form.url) %}
<span class="black-text">{{ form_errors(form.url) }}</span>
{% endif %}
{{ form_widget(form.url) }}
<div class="hidden">{{ form_rest(form) }}</div>
</form>

View File

@ -20,7 +20,7 @@
<div id="set1" class="col s12">
<a href="{{ path('new_entry') }}">{% trans %}Thanks to this form{% endtrans %}</a>
<a href="{{ path('new') }}">{% trans %}Thanks to this form{% endtrans %}</a>
</div>

View File

@ -58,7 +58,7 @@
</div>
<div class="input-field nav-panel-buttom">
<ul>
<li class="bold"><a class="waves-effect" href="{{ path('new_entry') }}" id="nav-btn-add"><i class="mdi-content-add"></i></a></li>
<li class="bold"><a class="waves-effect" href="{{ path('new') }}" id="nav-btn-add"><i class="mdi-content-add"></i></a></li>
<li><a class="waves-effect" href="javascript: void(null);" id="nav-btn-search"><i class="mdi-action-search"></i></a>
</ul>
</div>
@ -69,6 +69,11 @@
<i class="mdi-navigation-close"></i>
</div>
</form>
<div class="input-field nav-panel-add" style="display: none">
{{ render(controller( "WallabagCoreBundle:Entry:addEntryForm" )) }}
<label for="add"><i class="mdi-content-add"></i></label>
<i class="mdi-navigation-close"></i>
</div>
<!--<form name="entry" method="post" action="{{ path('new_entry') }}">
<div class="input-field nav-panel-add" style="display: none">
<input id="add entry_url" name="entry[url]" type="search" required placeholder="{% trans %}Enter your link here{% endtrans %}">
@ -113,4 +118,4 @@
</div>
</div>
</footer>
{% endblock %}
{% endblock %}

View File

@ -6,15 +6,16 @@ $(document).ready(function(){
accordion : false
});
//$('#nav-btn-add').click(function(){
// $(".nav-panel-buttom").hide(100);
// $(".nav-panel-add").show(100);
// $(".nav-panel-menu").hide(100);
// $(".nav-panels .action").hide(100);
// $(".nav-panel-menu").addClass('hidden');
// $(".nav-panels").css('background', 'white');
// return false;
//});
$('#nav-btn-add').click(function(){
$(".nav-panel-buttom").hide(100);
$(".nav-panel-add").show(100);
$(".nav-panel-menu").hide(100);
$(".nav-panels .action").hide(100);
$(".nav-panel-menu").addClass('hidden');
$(".nav-panels").css('background', 'white');
$("#entry_url").focus();
return false;
});
$('#nav-btn-search').click(function(){
$(".nav-panel-buttom").hide(100);
$(".nav-panel-search").show(100);