Hi guys,
I'm stucked with the way Symfony2 works now (which I really like,
don't get me wrong). I have a simple layout in my bundle which always
includes a search form, this is what I've done so far:
{% extends "::layout.twig.html" %}
{% block body %}
<h1>Application</h1>
{% render "MyApplicationBundle:Tag:search" %}
{% block content %}
{% endblock %}
{% endblock %}
This is my search action :
public function searchAction()
{
$tag = new Tag();
$form = new Form('search', $tag, $this->get('validator'));
$form->add(new TextField('name'));
$request = $this->get('request');
if ($request->isXMLHttpRequest())
{
$response = $this->createResponse();
$response->headers->set('Content-Type', 'application/json');
// TODO : perform search
$response->setContent(json_encode(array('Symfony', 'Ohai')));
return $response;
}
return $this->render('MyApplicationBundle:Tag:search.twig.html',
array(
'form' => $form
));
}
This looks really messy to me, here is what I want :
- A component including the search form
- An action handling search request displaying results in an HTML view
(for now it doesn't work / JSON encoded content if AJAX
Should I split my code into 2 actions? How would you name them? I must
admit I'm confused :-)
Thanks for your help !
Romain
--
If you want to report a vulnerability issue on symfony, please send it to
security at symfony-project.com
You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en