Skip to content

Instantly share code, notes, and snippets.

View czarpino's full-sized avatar

Czar Pino czarpino

View GitHub Profile
@czarpino
czarpino / gist:5625692
Last active December 17, 2015 14:39
php, doctrine2, symfony2, form-validation

Refresh Entity on Failed Validation

An often overlooked step when updating an entity is reverting invalid changes. While often unnecessary, doing so is borderline good practice.

Here is a typical edit controller which renders a pre-filled form and validates changes to the entity being edited.

/**
 * Edit user attributes