Instantly share code, notes, and snippets.

@szatan szatan/gist:5291554
Created Apr 2, 2013

What would you like to do?
namespace Acme\DemoBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Symfony\Component\HttpFoundation\Request;
use Acme\DemoBundle\Form\Type\SettingsFormType;
class SettingsController extends Controller
* The action to manipulate application wide settings
* @Route("/settings", name="manage_settings")
* @Template()
* @param \Symfony\Component\HttpFoundation\Request $request
public function settingsAction(Request $request)
$form = $this->createForm(new SettingsFormType($this->get('settings')));
if ($request->isMethod('POST')) {
if ($form->isValid()) {
foreach ($form->getViewData() as $key => $data) {
$settingKey = str_replace('_', '.', $key);
$this->get('settings')->set($settingKey, $data);
$this->get('session')->getFlashBag()->add('success', 'The settings have been saved');
return array(
'form' => $form->createView()

This comment has been minimized.

Copy link

bartoszrychlicki commented Apr 2, 2013

Add an openning <?php tag to enable syntax coloring

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment