Skip to content

Instantly share code, notes, and snippets.

@mjuchli
Created May 17, 2013 08:50
Show Gist options
  • Save mjuchli/5597842 to your computer and use it in GitHub Desktop.
Save mjuchli/5597842 to your computer and use it in GitHub Desktop.
A simple hack to issue https://github.com/sonata-project/SonataFormatterBundle/issues/19 Data is stored in content instead of rawContent.
<?php
/*
* This file is part of the Sonata project.
*
* (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Application\Sonata\FormatterBundle\Block;
use Sonata\FormatterBundle\SonataFormatterBundle;
use Symfony\Component\HttpFoundation\Response;
use Sonata\AdminBundle\Form\FormMapper;
use Sonata\AdminBundle\Validator\ErrorElement;
use Sonata\BlockBundle\Model\BlockInterface;
use Sonata\BlockBundle\Block\BaseBlockService;
use Sonata\FormatterBundle\Block\FormatterBlockService as BaseFormatterBlockService;
/**
* In order to keep data in textarea, data will be stored in content (not rawContent).
* For more information see issue: https://github.com/sonata-project/SonataFormatterBundle/issues/19
*
* @author Marc Juchli <mj@codag.ch>
*/
class FormatterBlockService extends BaseFormatterBlockService
{
/**
* {@inheritdoc}
*/
public function buildEditForm(FormMapper $formMapper, BlockInterface $block)
{
$formMapper->add('settings', 'sonata_type_immutable_array', array(
'keys' => array(
array('format', 'sonata_formatter_type_selector', array(
'source' => 'content',
'target' => '[content]',
'listener' => true,
)),
array('content', 'textarea', array()),
)
));
}
public function getParent()
{
return 'Formatter';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment