Permalink
Browse files

Also support output_mode for textareas

  • Loading branch information...
flack committed Dec 16, 2017
1 parent 43e99e4 commit 63154b17ce1f65595ce0d2be7db492e631866ef3
Showing with 55 additions and 0 deletions.
  1. +41 −0 src/midcom/datamanager/extension/type/textarea.php
  2. +14 −0 src/midcom/datamanager/template/view.php
@@ -0,0 +1,41 @@
<?php
/**
* @copyright CONTENT CONTROL GmbH, http://www.contentcontrol-berlin.de
*/
namespace midcom\datamanager\extension\type;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\OptionsResolver\Options;
use Symfony\Component\Form\FormView;
use Symfony\Component\Form\FormInterface;
use midcom\datamanager\extension\helper;
/**
* Experimental textarea type
*/
class textarea extends TextareaType
{
/**
* {@inheritdoc}
*/
public function configureOptions(OptionsResolver $resolver)
{
parent::configureOptions($resolver);
$resolver->setNormalizer('type_config', function (Options $options, $value) {
$type_defaults = [
'output_mode' => 'html',
'specialchars_quotes' => ENT_QUOTES,
'specialchars_charset' => 'UTF-8'
];
return helper::resolve_options($type_defaults, $value);
});
}
public function finishView(FormView $view, FormInterface $form, array $options)
{
$view->vars['output_mode'] = $options['type_config']['output_mode'];
}
}
@@ -10,6 +10,20 @@ class view extends base
{
private $skip_empty = false;
/**
* Define the quotes behavior when htmlspecialchars() is called
*
* @see http://www.php.net/htmlspecialchars
*/
private $specialchars_quotes = ENT_QUOTES;
/**
* Define the charset to use when htmlspecialchars() is called
*
* @see http://www.php.net/htmlspecialchars
*/
private $specialchars_charset = 'UTF-8';
public function __construct($renderer, $skip_empty = false)
{
parent::__construct($renderer);

0 comments on commit 63154b1

Please sign in to comment.