Add proper HTML filtering to render mailto links and formatting in vendor notes. - Create HtmlArraySerialized backend model to prevent HTML escaping - Add filterOutputHtml() method to safely render HTML content - Update template to use HTML filtering - Decode HTML entities before display
32 lines
875 B
PHP
32 lines
875 B
PHP
<?php
|
|
namespace Shopkeeper\VendorNotes\Model\Config\Backend;
|
|
|
|
use Magento\Config\Model\Config\Backend\Serialized\ArraySerialized;
|
|
|
|
class HtmlArraySerialized extends ArraySerialized
|
|
{
|
|
/**
|
|
* Process data before saving
|
|
* Prevent HTML from being escaped in note fields
|
|
*
|
|
* @return $this
|
|
*/
|
|
public function beforeSave()
|
|
{
|
|
$value = $this->getValue();
|
|
|
|
if (is_array($value)) {
|
|
// Don't escape HTML in the note field
|
|
foreach ($value as &$row) {
|
|
if (isset($row['note'])) {
|
|
// Decode any previously encoded HTML entities
|
|
$row['note'] = html_entity_decode($row['note'], ENT_QUOTES, 'UTF-8');
|
|
}
|
|
}
|
|
unset($row);
|
|
}
|
|
|
|
$this->setValue($value);
|
|
return parent::beforeSave();
|
|
}
|
|
} |