Skip to content

Instantly share code, notes, and snippets.

@ideadapt
Created January 17, 2012 14:50
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ideadapt/1626913 to your computer and use it in GitHub Desktop.
Save ideadapt/1626913 to your computer and use it in GitHub Desktop.
add tinymce to form field in symfony2
$formMapper
->with('General')
->add('title')
->add('blog', 'textarea', array('attr' => array('class' => 'tinymce', 'tinymce'=>'{"theme":"simple"}')))
@Sergic
Copy link

Sergic commented Jan 30, 2012

i can't to understand but it does not work
i have added this array(‘attr’ => array(‘class’ => ‘tinymce’, ‘tinymce’=>’{“theme”:”simple”}’)) in sonata admin but nothing happens
wtf?
it returns me only textarea with class="sonata-medium"

@ideadapt
Copy link
Author

ideadapt commented Feb 1, 2012

Maybe its a problem with the quotes. In my original gist I somehow pasted with wrong quotes (e.g. ” instead of "). The updated version should be correct. If it still does not work make sure if your php code is actually being invoked.

@Sergic
Copy link

Sergic commented Feb 2, 2012

no problem with quotes and i use latest version of sonata bundle
it simply does not return css class in array.
i wrote array(‘attr’ => array(‘class’ => ‘tinymce’));
nothing (((
only return class="sonata-medium"
i don't know what to do

@Sergic
Copy link

Sergic commented Feb 2, 2012

found class
vendor\bundles\Sonata\AdminBundle\Form\Extension\Field\Type\FormTypeFieldExtension.php
string 110 $attr = $view->get('attr', array());
this class does not get attr param from formMapper why? and how to debug it....

@ideadapt
Copy link
Author

ideadapt commented Feb 2, 2012

To debug you can write to a logger and check the logfile after the request. See http://symfony.com/doc/current/cookbook/logging/monolog.html. Or you could debug your php code using xdebug ...
I have the FormTypeFieldExtension.php file too, with the same content as you do. I didnt change it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment