Search from index page.

This commit is contained in:
Alexey Skobkin 2015-05-31 10:02:00 +03:00
parent ce0b6e856f
commit 58f8db6c97
3 changed files with 22 additions and 2 deletions

View file

@ -9,6 +9,7 @@ use Skobkin\Bundle\PointToolsBundle\Entity\TopUserDTO;
use Skobkin\Bundle\PointToolsBundle\Entity\User; use Skobkin\Bundle\PointToolsBundle\Entity\User;
use Skobkin\Bundle\PointToolsBundle\Service\UserApi; use Skobkin\Bundle\PointToolsBundle\Service\UserApi;
use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
class UserController extends Controller class UserController extends Controller
{ {
@ -72,4 +73,17 @@ class UserController extends Controller
'top_users' => $topUsers 'top_users' => $topUsers
]); ]);
} }
/**
* @param Request $request
*/
public function searchUserAction(Request $request)
{
$login = $request->request->get('login');
if (!$login) {
throw new \InvalidArgumentException('No login information present');
}
return $this->redirectToRoute('user_show', ['login' => $login]);
}
} }

View file

@ -2,6 +2,11 @@ index:
path: / path: /
defaults: { _controller: SkobkinPointToolsBundle:Main:index } defaults: { _controller: SkobkinPointToolsBundle:Main:index }
user_search:
path: /search
defaults: { _controller: SkobkinPointToolsBundle:User:searchUser }
methods: [POST]
user_show: user_show:
path: /user/{login} path: /user/{login}
defaults: { _controller: SkobkinPointToolsBundle:User:show } defaults: { _controller: SkobkinPointToolsBundle:User:show }

View file

@ -2,12 +2,13 @@
{% block content %} {% block content %}
<div class="well well-lg"> <div class="well well-lg">
<form class="form-inline"> {# @todo rewrite to Symfony forms #}
<form class="form-inline" method="post" action="{{ url('user_search') }}">
<div class="form-group"> <div class="form-group">
<label class="sr-only" for="index-input-username">Username</label> <label class="sr-only" for="index-input-username">Username</label>
<div class="input-group"> <div class="input-group">
<div class="input-group-addon">@</div> <div class="input-group-addon">@</div>
<input type="text" class="form-control" id="index-input-username" placeholder="username"> <input name="login" type="text" class="form-control" id="index-input-username" placeholder="username">
</div> </div>
</div> </div>
<button type="submit" class="btn btn-primary">Search</button> <button type="submit" class="btn btn-primary">Search</button>