New in symfony 1.2: Small things matter (2)

Symfony 1.2 already comes with a lot of great new features but smaller things also matter a lot. Here is yet another post about small things we have recently added to symfony 1.2.


In an action, you can now generate a URL by using the routing object directly thanks to the new generateUrl() proxy method:

public function executeIndex()

The generateUrl() method takes a route name, an array of parameters, and whether to generate an absolute URL as its constructor arguments.


We have added two new methods to sfForm that ease form handling in the templates.

The first one, hasErrors() returns true if the form has some errors and false otherwise. This method also returns false if the form is not bound. It is quite useful in a template when you want to display a message when a form has some errors:

<?php if ($form->hasErrors()): ?>
  The form has some errors you need to fix.
<?php endif; ?>

The second one, renderFormTag() generates the opening form tag for the current form. It also adds the enctype attribute if the form needs to be multipart and adds a hidden tag if the form method is not GET or POST:

<?php echo $form->renderFormTag(url_for('@article_update'), array('method' => 'PUT')) ?>

When a form is tied to a Propel object, the renderFormTag() method automatically changes the HTTP method based on the related object: it changes the method to POST for new objects, and to PUT for existing objects.

Propel tasks

The Propel tasks relying on Phing now output clears error messages if the embed Phing task fails.

propel error message

To ease the debugging, the propel:build-model, propel:build-all, and propel:build-all-load tasks also do not remove the generated XML schemas anymore if you pass the --trace option.

The propel:insert-sql task removes all the data from the database before re-creating all the tables. As it destroys information, it now asks the user to confirm the execution of the task. The same goes for the propel:build-all and propel:build-all-load tasks, as they call the propel:insert-sql task.

propel task confirmation

If you want to use these tasks in a batch and want to avoid the confirmation, pass the --no-confirmation option:

$ php symfony propel:insert-sql --no-confirmation

As for every release, symfony simplifies the developer life by providing more shortcuts and nicer error messages.


Thanks Fabien!
A typo: "The first one, hasErrors() returns true if the form has no error and false otherwise." -> I presume the "no" should not be there.
Cheers R.
Regarding small things matter, I like to add another neat thing: there will be a very useful form widget for a list of checkboxes... something that is missing in the current release! I was just about to write my own, when I found this gem in the 1.2 branch! Thanks Fabien, thanks symfony!
Symfony ever better with each release.
Way to go and thank you!
Good thing for the build-all-load protection, especially when you have a unix shell for staging and one for prod env ..!

Comments are closed.

To ensure that comments stay relevant, they are closed for old posts.