Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

FinalConcept.com.au:
Symfony: Unbound sfForm: Unexpected extra form field named
Jun 29, 2010 @ 16:13:21

In a recent post to the FinalConcept blog there's a helpful hint for Symfony developers looking to be rid of a pesky "unexpected form field" error that might pop up - finxing it with a validator.

In this use case we have an exiting model that describes an Article. We want to be able edit the Article and have the option to send and email to an address defined in a text box. However we don't want the email field to be bound to the form and we dont want to add the email address to the Article.

The trick is to add a validator to the form's definition (like a normal field) but to include a "sfValidatorPass" into the validatorSchema and it'll skip right over it. You can find out more about Symfony forms on the Symfony project website.

tagged: symfony form error unbound sfform

Link:

Ian Christian's Blog:
Embedded forms using Javascript with sfForm
Nov 13, 2009 @ 16:03:37

In this recent post to his blog Ian Christian looks at how to use the sfForm component of the Symfony framework to create dynamic sub-forms without a refresh to build it.

wanted to create a form that allowed me to dynamically add sub-forms via JS, without round-trips to the server. I had a bit of a google, but failed to find much of use - so I wrote my own. This article contains my code for a proof of concept, and a brief description of what it does. It is proof of concept, and done as an example, so code isn't done perhaps as I might do in a real configuration, but I hope it provides help to others.

His end result lets you dynamically load in new form elements via some jQuery trickery. Complete code for the Javascript, view, form and the YAML markup for the model are included.

tagged: sfform symfony framework tutorial dynamic subform

Link:

Fabien Potencier's Blog:
PHP Serialization, Stack Traces, and Exceptions
Feb 11, 2009 @ 16:27:54

Fabien Potencier has a new post about a strange and hard to track down bug he was experiencing with serializing a symfony form - it was throwing a PDO exception.

This exception is thrown by PDO because PDO instances are not serializable for good reasons. But it is weird because the sfForm class does not depend on PDO. How is it possible?

After some poking around, he noticed that this was only an issue for those with sessions stored in the database (that's where the PDO comes in). The problem came with the validation error class - it extends the exception class and, because of how the error handling serializes the exception, it tries to serialize the PDO connection that's in the stack trace too.

His solution is to use a Serializable interface to define exactly what you want serialized and passed back out as the error to the rest of your script.

tagged: stacktrace exception serialize pdo sfform symfony framework

Link:


Trending Topics: