Input’s not editable after using Jquery Sortable

fry_coffeeJquery, I love it.

Here’s a little gotcha that I often overlook – especially when copy/pasting from the Jqueryui.com Sortable example.

If you have applied:

$( "#sortable" ).disableSelection();

Then when you finish your sorting, you won’t be able to edit any input boxes – yet check boxes and radios will still work.

The solution is mighty simple:

$( "#sortable" ).enableSelection();

Doh.

An exception has been thrown during the rendering of a template (“You have requested a non-existent service “http”

Nick-Hewer-Countdown-007I have been running v2.1.10-dev since very shortly after it was released – as I run composer update nightly.

However, I keep finding this error:


An exception has been thrown during the rendering of a template (“You have requested a non-existent service “http” *cut*

After doing an assetic:dump.

As soon as I do an assetic:dump, then a php app/console -V, my version changes from 2.1.10-dev to 2.1.4-dev.

The error above is then thrown when opening a template that uses a render(route) call inside my twig template.

It’s not major, in that running composer update resolves the issue.

For reference, I have deleted the app/cache dir with rm -rf *, as well as cache:clear. I have done this multiple times.

I have decided to remove the entire Symfony folder from vendors (sudo rm -rf vendors/symfony/*) and re-run the composer update.

Hopefully this will clear the issue.

Note: I have resolved the issue raised on the Official Symfony Blog, so if you are seeing this after updating, have Googled and found this page, then you probably haven’t corrected the issue raised on the blog article. Specifically point 6, but make sure to read it all.

And if anyone has got the same issue as I have, please let me know how you resolved it.

If I haven’t updated this post in 7 days, you can take my solution (deleting the Symfony folder from vendors) as working.

Otherwise, I am sure to be back here having a rant.

Ps, yes I am aware the post picture is irrelevant.

How to fix Method Not Found In Class orange warning in PHPStorm

little-miss-helpfulGrrr, how annoying.

My screen is full of orange, but I know these methods are valid.

Your project may be vast in scope, you may have a looming deadline for 5pm tonight, or you may just be a perfectionist who hates the thought of your IDE thinking you are making mistakes.

A good example of this is when using a foreach loop.

You have something like:

foreach( $myEntity as $entity ) {
  $entity->myValidMethod();
}

And PHPStorm says, erm, you make big mistake sir!

Now you have a valid bit of code that’s flagged up in orange as Method ‘myValidMethod’ not found in class My\Name\Space\Path\MyEntity.

Boo, hiss, and such.

It’s simple to fix though – even though it’s taken me over 100 words to get here.

Just add a comment, as such:

/* @var $entity \My\Name\Space\Path\MyEntity */
foreach( $myEntity as $entity ) {
  $entity->myValidMethod();
}

Super.

Now you no longer have a false positive.

Time to get back to meeting your deadline.

How to fix Twig Whitescreen on {{dump(var)}}

This one has been doing my head in for a while now.

Once your forms get past a certain size / complexity, the {{dump(var)}} command tends to bomb out, and throw up a rather unhelpful white screen.

Many of the results on Google tend to say – increase your PHP memory limit – never has more of an impact than taking longer to display the damn white screen.

Boo hiss, shake your first at things, etc.

Anyway, I finally found a solution.

Get your project back on track with the Ladybug Bundle.

{{ ladybug_dump(form) }}

A little of the above gives you a little of the below.

And yes, each section is expandable to give you loads of helpful detail.

example-twig-dump-ladybug-bundle

Excuse the crappy screengrab – I had to resize to get it to fit and it looks gashbag. Hey, I never said I was a designer.

Just a kick ass Symfony 2 expert 😉

Adding new objects to a form field collection

homer-dohI couldn’t think of a good title for this post. So, erm, sorry about that.

Still, if you are reading on, this may save you a headache in the future.

I came across an issue today where I was basically doing this (adding a new option at run time to a form), and it worked.

Kind of.

It would always add in the first option.

And it would add in the second option too, should I add one.

But any above the second were always lost. I couldn’t figure out why the submitted array only ever contained, at most, two items.

Out of sheer luck, I also had another collection sub form inside the very same form, which I had basically copy/pasted from.

Now, this made the whole – why the *expletive deleted* isn’t this thing working?

Turns out, I had set my prototype_name in my Form Type to something different to that in the .text().replace(regex) in my javascript.

Doh.

Still – at least I know for the future. And hopefully, if you ever make a similar mistake, you will now know how to rectify it quickly.