Symfony2: Forms and Ajax

Making Ajax calls is a trivial task nowadays for any web developer, and I'm sure it's no enigma for all of you how to do it using your favourite Javascript library or framework like jQuery, Angular, Backbone, you name it.   But how do we handle these requests in the backend? More specifically, how should we write our controllers to take full advantage of our preferred framework, Symfony 2 in…

10 Awesome CSS Tips and Tricks

This is a collection of CSS tips, tricks, and fixes, or whatever you want to call them, that I stumbled upon along the way. I have to say from the very beginning that you can find most of these, if not all of them, familiar. On the other hand, I really hope that some of you might learn something new from this post. So let's begin.

How to Add Share Buttons to Symfony2 Generated Web Pages

Some projects require you to add social share buttons for their pages. I'm gonna show you a simple way to do this using the Socialitejs JavaScript library. First you're gonna have to download the Socialitejs library, save it to your bundle Resources/public/js folder and publish the assets. If you have a general layout that is inherited by all your specific page templates (like it's usually the…

How to (Easily) Debug a Rails Application

Hello all you party people! This article will show you how you can easily debug your Rails code. If you're using the default Rails Rack server, Webrick - the best debugging tool I've been able to find out there is pry. Its use is pretty straightforward: First off you'd need to add the pry gem to your Gemfile. Since this is used for development purposes, it should be added in the :development…

Symfony2: Gedmo SoftDeletable Doctrine Entities with Unique Index Columns

There is a problem when using the SoftDeletable Doctrine extension for entities that have some unique index columns. The most obvious example is User entities. An User has at least one column that needs to be unique (username and/or email). When soft-deleting an User the actual record will stay in the db table. Now if you try to create a new one with the same username/email, the validation will…

How to Convert Web (HTML) Pages into PDF Files

Here's a collection of steps needed to create PDF files directly from HTML web pages. If you're working on a Ubuntu Linux machine, the first thing you need to do is to install the WKHTMLTOPDF library, by running the following commands into your terminal:

Symfony2: How to Get the Label for a Specific Form Field in Twig

If you need to render the label value for a specific field without rendering the entire HTML label element (e. g. to use it for a placeholder), you can do it by using the label form variable: [crayon-60fade88c24da667320022/]

Symfony2: How to Check If a Form Field Has Errors in Twig

Sometimes you need to check if a field or even the entire form has errors before rendering them (e.g. when adding an errors container). Here's the code snippet that allows you to check for the errors form variable: [crayon-60fade88c26d6404030186/]