integrate form into admin part

This commit is contained in:
Manuel Raynaud
2013-06-25 14:30:35 +02:00
parent 1fc1482ac4
commit 7bc1b4f513
5 changed files with 73 additions and 18 deletions

View File

@@ -1,19 +1,55 @@
<?php
/**
* Created by JetBrains PhpStorm.
* User: manu
* Date: 20/06/13
* Time: 12:05
* To change this template use File | Settings | File Templates.
*/
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Admin\Controller;
use Thelia\Form\AdminLogin;
class AdminController extends BaseAdminController {
public function indexAction()
{
return $this->render("login.html");
$form = $this->getFormBuilder();
$adminLogin = new AdminLogin();
$form = $adminLogin->buildForm($form, array())->getForm();
$request = $this->getRequest();
if($request->isMethod("POST")) {
$form->bind($request);
if($form->isValid()) {
//TODO
} else {
//TODO
}
}
return $this->render("login.html", array(
"form" => $form->createView()
));
}
}

View File

@@ -24,6 +24,10 @@ namespace Thelia\Admin\Controller;
use Symfony\Component\Routing\RequestContext;
use Symfony\Component\DependencyInjection\ContainerAware;
use Symfony\Component\HttpFoundation\Response;
use Thelia\Form\BaseForm;
use Thelia\Model\ConfigQuery;
/**
*
@@ -44,7 +48,7 @@ class BaseAdminController extends ContainerAware
*/
public function render($templateName, $args = array())
{
$args = array('lang' => 'fr');
$args = array_merge($args, array('lang' => 'fr'));
$response = new Response();
@@ -53,7 +57,7 @@ class BaseAdminController extends ContainerAware
public function renderRaw($templateName, $args = array())
{
$args = array('lang' => 'fr');
$args = array_merge($args, array('lang' => 'fr'));
return $this->getParser()->render($templateName, $args);
}
@@ -76,5 +80,15 @@ class BaseAdminController extends ContainerAware
return $parser;
}
public function getFormFactory()
{
return BaseForm::getFormFactory($this->getRequest(), ConfigQuery::read("form.secret.admin", md5(__DIR__)));
}
public function getFormBuilder()
{
return $this->getFormFactory()->createBuilder("form");
}
}