Jump to content

Edit History

jackflyer

jackflyer

Hi,

I am coding a custom module, which is just doing some computation from data input by the user in a form (without e-commerce functionality).

I want to give back the answer, which is a numerical value and other values computed from the first, shown in a table.
I got inspired from the ps_emailsubscription module, which uses return $this->valid = 'string' to answer in a green box located below the form. 
I can return a string or a number but I want to display a table, so I tried this in mymodule.php

public function myModule($hookName = null)
  {
	...math computation from values input by user in form...
	$html = '<table><thead><tr><th></th><th>firstCol</th><th>secondCol</th><th>third</th><th>fourth<Col/th></tr></thead>';
  	$html .= '<tr><td></td><td>bla</td><td>bla</td><td>bla</td><td>bla</td></tr>';
  	$html .= '</table>';   
  	return $this->valid = $this->trans('blabla = %firstResult% blabla ', ['%firstResult%' => $firstResult], 'Modules.Mymodule.Mymodule') . $html;
}

The html code is displayed but not interpreted. How can I make it interpreted ? Or display my result table with another manner ?
I tried htmlspecialchars($html), htmlentities($html) but I just get things like "&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&"
html_entity_decode($html) has no effect.

Maybe "this->valid" has a special stuff preventing the html to be interpreted but I have no idea where to find its implementation. 

Thank you

Pierre

jackflyer

jackflyer

Hi,

I am coding a custom module, which is just doing some computation from data input by the user in a form (without e-commerce functionality).

I want to give back the answer, which is a numerical value and other values computed from the first, shown in a table.
I got inspired from the ps_emailsubscription module, which uses return $this->valid = 'string' to answer in a green box located below the form. 
I can return a string or a number but I want to display a table, so I tried this in mymodule.php

public function myModule($hookName = null)
  {
	...math computation from values input by user in form...
	$html = '<table><thead><tr><th></th><th>firstCol</th><th>secondCol</th><th>third</th><th>fourth<Col/th></tr></thead>';
  	$html .= '<tr><td></td><td>bla</td><td>bla</td><td>bla</td><td>bla</td></tr>';
  	$html .= '</table>';   
  	return $this->valid = $this->trans('blabla = %firstResult% blabla ', ['%firstResult%' => $firstResult], 'Modules.Mymodule.Mymodule') . $html;
}

The html code is displayed but not interpreted. How can I make it interpreted ? Or display my result table with another manner ?
I tried htmlspecialchars($html), htmlentities($html) but I just get things like "&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&"

Maybe "this->valid" has a special stuff preventing the html to be interpreted but I have no idea where to find its implementation. 

Thank you

Pierre

×
×
  • Create New...