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 * @param Request $request
* *
* @Route("/new", name="new_entry") * @Route("/new-entry", name="new_entry")
* *
* @return \Symfony\Component\HttpFoundation\Response * @return \Symfony\Component\HttpFoundation\Response
*/ */
public function addEntryAction(Request $request) public function addEntryFormAction(Request $request)
{ {
$entry = new Entry($this->getUser()); $entry = new Entry($this->getUser());
@ -45,11 +45,23 @@ class EntryController extends Controller
return $this->redirect($this->generateUrl('homepage')); 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(), '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. * Edit an entry content.
* *

View file

@ -3,5 +3,5 @@
{% block title %}{% trans %}Save new entry{% endtrans %}{% endblock %} {% block title %}{% trans %}Save new entry{% endtrans %}{% endblock %}
{% block content %} {% block content %}
{{ form(form) }} {{ render(controller( "WallabagCoreBundle:Entry:addEntryForm" )) }}
{% endblock %} {% 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> <p>{% trans %}There are several ways to save an article:{% endtrans %}</p>
<ul> <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> </ul>
<h3>{% trans %}Browser Addons{% endtrans %}</h3> <h3>{% trans %}Browser Addons{% endtrans %}</h3>
<ul> <ul>

View file

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

View file

@ -3,38 +3,5 @@
{% block title %}{% trans %}Save new entry{% endtrans %}{% endblock %} {% block title %}{% trans %}Save new entry{% endtrans %}{% endblock %}
{% block content %} {% block content %}
<div class="row"> {{ render(controller( "WallabagCoreBundle:Entry:addEntryForm" )) }}
<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>
{% endblock %} {% 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"> <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> </div>

View file

@ -58,7 +58,7 @@
</div> </div>
<div class="input-field nav-panel-buttom"> <div class="input-field nav-panel-buttom">
<ul> <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> <li><a class="waves-effect" href="javascript: void(null);" id="nav-btn-search"><i class="mdi-action-search"></i></a>
</ul> </ul>
</div> </div>
@ -69,6 +69,11 @@
<i class="mdi-navigation-close"></i> <i class="mdi-navigation-close"></i>
</div> </div>
</form> </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') }}"> <!--<form name="entry" method="post" action="{{ path('new_entry') }}">
<div class="input-field nav-panel-add" style="display: none"> <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 %}"> <input id="add entry_url" name="entry[url]" type="search" required placeholder="{% trans %}Enter your link here{% endtrans %}">

View file

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