en Jump to content
  • 0

[solved] Saving text as HTML in Configuration table




I'm creating a simple module in which it should be possible to enter HTML / CSS / JS in the backend, this should be saved in the database, and in the frontend this should be parsed in a .tpl file and output the given HTML / CSS / JS.


right now I have the following part to build a form:


// form for settings
	$aFormFields = array();
	$aFormFields[0]['form'] = array(
		'tinymce' => true,
		'legend' => array(
			'title' => $this->l('Parallax settings'),
		'input' => array(
				'type' => 'textarea',
				'label' => $this->l('Upload images'),
				'name' => 'PARALLEX_RTE_FIELD',
				'cols' => 100,
				'rows' => 60
		'submit' => array(
			'title' => $this->l('Save'),
			'class' => 'button'

	$oHelper = new HelperForm();

	// Module, token and currentIndex
	$oHelper->module = $this;
	$oHelper->name_controller = $this->name;
	$oHelper->token = Tools::getAdminTokenLite('AdminModules');
	$oHelper->currentIndex = AdminController::$currentIndex.'&configure='.$this->name;
	// Language
	$oHelper->default_form_language = $iLang;
	$oHelper->allow_employee_form_lang = $iLang;
	// Title and toolbar
	$oHelper->title = $this->displayName;
	$oHelper->show_toolbar = true;		// false -> remove toolbar
	$oHelper->toolbar_scroll = true;	  // yes - > Toolbar is always visible on the top of the screen.
	$oHelper->submit_action = 'submit'.$this->name;
	$oHelper->toolbar_btn = array(
		'save' =>
			'desc' => $this->l('Save'),
			'href' => AdminController::$currentIndex.'&configure='.$this->name.'&save'.$this->name.
		'back' => array(
			'href' => AdminController::$currentIndex.'&token='.Tools::getAdminTokenLite('AdminModules'),
			'desc' => $this->l('Back to list')
	// Load current values
	$oHelper->fields_value['PARALLEX_RTE_FIELD'] = Configuration::get('PARALLEX_RTE_FIELD');

	$sReturn = $oHelper->generateForm($aFormFields);

	return $sReturn;


this part to save it in the database:


if (Tools::isSubmit('submit'.$this->name)){
		Configuration::updateValue('PARALLEX_RTE_FIELD', Tools::getValue('PARALLEX_RTE_FIELD'));
		$sOutput .= $this->displayConfirmation($this->l('Changes saved'));


this part to give it to the template:

		'parallax_data' => Configuration::get('PARALLEX_RTE_FIELD')
	return $this->display(__FILE__, 'parallax.tpl');


and this is how I show it in the template file:



now my problem is that it seems that HTML data is being filtered out. my code works, in the frontend I can see that the data I insert in the backend is shown, but it's not working HTML anymore.


What I would like is that literally what I enter in the backend is being shown as HTML in frontend.any clue on how to fix this?

Share this post

Link to post
Share on other sites

5 answers to this question

Recommended Posts

  • 0

I think in your writing the value to the database, you should add a

, true

to the statement:

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

in the file /classes/Configuration.php you can see the definition of the updateValue function. The third parameter defines if html is allowed or not:

  * Update configuration key and value into database (automatically insert if key does not exist)
  * @param string $key Key
  * @param mixed $values $values is an array if the configuration is multilingual, a single string else.
  * @param boolean $html Specify if html is authorized in value    <--- this defines if html values allowed or not
  * @param int $id_shop_group
  * @param int $id_shop
  * @return boolean Update result
public static function updateValue($key, $values, $html = false, $id_shop_group = null, $id_shop = null)


Default value is set to false, so if you turn it on, it might work as wanted.

Give it a try and see if it helps. If not yet, we have to find out if there's more to do.


My 2 cents,


Share this post

Link to post
Share on other sites
  • 0

thanks for information that it works

now i can go ahead and mark this thread as [solved]


you can also mark own threads as solved, read the instruction:

To mark a topic as [solved] :

- Edit the first post of your topic by clicking on the "Edit" button,

- Click on the "Use full editor" button,


- Add the "[solved]" string at the beginning of your topic title and click on the "Submit Modified Post" button.


we will be grateful if you will follow these steps in the future,



Share this post

Link to post
Share on other sites

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


Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More