Catch Symfony Form Errors

Have you built a form while developing with the symfony form framework that appears to work fine but fails because of an unknown error? Here is the simplest and easiest way to catch most errors.

First open the web page with the form and fill it in with valid input. Then, open the form php file, temporarily delete all your custom form render code and replace it with echo $form. Go back to the web page and click your form submit button. It should show you any validation errors that appear in the form but were missing on your customized version, because this time it’s rendering the form with the default settings. At the very least it could show you something you missed and hint at the solution.

Your test form would look like this:

<form action="<?php echo url_for('user/'.($form->getObject()->isNew() ? 'create' : 'update').(!$form->getObject()->isNew() ? '?id='.$form->getObject()->getId() : '')) ?>" method="post" <?php $form->isMultipart() and print 'enctype="multipart/form-data" ' ?>>
<table>
  <tfoot>
  <tr>
    <td>
      <?php echo $form->renderHiddenFields() ?>
      <input type="submit" value="Save">
    </td>
  </tr>
  </tfoot>
  <tbody>
    <?php echo $form ?>
  </tbody>
</table>
</form>

Accelerated CSS Transforms

Recently the WebKit team added support for CSS transformations with 3D GPU acceleration. This means that soon we can built web applications that mimic desktop applications in graphical responsiveness. Charles Ying wrote a simple image gallery application that demos this new functionality.

This is definitely not yet ready for end users but it demonstrates the power of the web platform and where it is heading. With the native video tag, local and session storage, plus much faster JavaScript engines, browsers are changing from simply presenting information to being a fully interactive platform. It’s no surprise that Google is developing a web-browser operating system, called Chrome OS.

It is also quite encouraging to see the second browser war bring fresh ideas and increase the possibilities to the browser. Competition is great.

Demo of CSS Transforms
Snow Stack in WebKit Nightly r46091

The CSS Transforms were originally created at Apple by Dean Jackson, David Hyatt and Chris Marrin for the iPhone. Apple then improved the spec and submitted it to standardization at the W3C. Firefox 3.5 supports 2D css transforms but does not yet support the newer accelerated 3D animations.

So how does it work?

The images are put on the page using standard CSS and HTML, and they are then animated by JavaScript using these CSS properties:

-webkit-transition-property: -webkit-transform;
-webkit-transform: rotateY(45deg);
-webkit-transition-duration: 2s;

The transition property is set to transform, the transform is set to rotate the image in Y-space by 45 degrees, and the duration is set to 2s. With that, the web browser will take the current position of the image and rotate it by 45 degrees in 2 seconds, which produces an animation effect. How beautifully simple it is!

Symfony CRUD Generator

The symfony CRUD generator is a very useful tool for speeding up your web development. When you need a list of items that you can list and edit, you are most likely building a standard CRUD (create-read-update-delete) interface. This is common functionality that is found in most applications. Since this is such a common task, it makes perfect sense that the symfony web framework has a tool to build it for you.

For example: Lets say your web application allow users to sign-up (surprise!) and you need a user management tool in the admin section to manage these users. To create this in symfony, you’d run the following:

./symfony propel:generate-crud admin user User

This assumes you have an admin application, and a User model file. With that one line, it will create a listing of all users with the ability to edit and delete them. It generates HTML and PHP code that you can modify to your requirements. Fantastic for less than a minute of work!

The Importance of the HTML Video Tag

Since Firefox, Safari, and recently Chrome hit the browser scene, the web has been growing and improving at a much faster pace. The next evolution of the web comes in the form of HTML 5, the latest HTML standard that brings native video playback, offline storage, 2D drawing via the canvas tag among others features. Of those, the video tag is the most important and critical to the continued success of the open web.

Native video playback inside a web browser will now be as simple as embedding an image into a page:

<video src="http://example.com/yourvideo.ogg" controls></video>

The benefits of this are immediately obvious to any software developer. It’s a native tag so it fits in much better to the web platform, it can be controlled through JavaScript, and no more messing around with a black-box flash embed. Side benefits of this are bringing video to all users, not just the platforms that Flash supports (stable 64 bit version + iPhone version).

So far only Firefox 3.5 and Safari 4 have built in support for the video tag; Opera and Chrome support is in the works.

The web has flourished and grown to where it is today because it is based on open standards and because it is not controlled by any one company or organization. Lets continue to keep the web open and successful by using the new video tag.