Fix HTML rendering for vendor notes links
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
This commit is contained in:
32
etc/Model/Config/Backend/HtmlArraySerialized.php
Normal file
32
etc/Model/Config/Backend/HtmlArraySerialized.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user