Jump to content

Allow <br> tags in Modules Admin tinymce fields.


Anthony IVOL

Recommended Posts

Hi,

 

How to allow <br> tags in Modules Admin Fields ?

 

I have that in my tinymce config :

valid_children: "+*[*]",
valid_elements: "*[*]",

I tried then in Tools.php line 3703 in purifyHTML function:

$def->addElement('br', 'Block', 'Flow', 'Common', array());

then 

$def->addElement('br', 'Inline', 'Flow', 'Common', array());

then

$def->addElement('br');

then I have disabled the htmlPurifier library in Settings > General

 

But nothing seems to work.

 

Working with prestashop 1.7.1.2, and I declare my field like this in my module : 

array(
 'type' => 'textarea',
 'autoload_rte' => true,
 'lang' => true,
 'label' => $this->trans('Truc truc truc', array(), 'Modules.Page_About.Admin'),
 'name' => 'TRUC',
),

What am I doing wrong ?

 

Thanks

 

 

 

Link to comment
Share on other sites

Well, 

 

I checked what was actually sent by the form and the Tinymce looks to work well as this code dumps <br> tags :

dump(Tools::getValue('TRUC'));
die();
Configuration::updateValue('TRUC', Tools::getValue('TRUC'));

It means that the problem comes while :

Configuration::updateValue('TRUC', Tools::getValue('TRUC'));
Link to comment
Share on other sites

I feel a bit alone here...

 

But I found the solution, the Configuration::updateValue function takes a third argument $html that should be true :

public static function updateValue($key, $values, $html = false, $idShopGroup = null, $idShop = null)

so this :

Configuration::updateValue('TRUC', Tools::getValue('TRUC'));

becomes :

Configuration::updateValue('TRUC', Tools::getValue('TRUC'), true);

tadaaaa !

Edited by Anthony IVOL (see edit history)
  • Like 1
Link to comment
Share on other sites

  • 4 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...