HTML Entities Conversation


I know this topic came up many times and it was always recommended to disable writing html entities in modules, like this:

<br />$config['modules']['businesses'] = array(
        // ...
    'sanitize_input' => array('template','php'), // does still transform ü to &uuml;
    'sanitize_input' => FALSE, // same


// does that work?
$config['module_overwrites']['pages']['sanitize_input'] = ['php','template'];

All those examples didn't work.

The only thing that works is

<br />class Businesses_model extends Base_module_model { 
    public $auto_encode_entities = FALSE; // don't convert umlauts etc. to entities!
        // ...

I want to turn off entities conversion globally, for every field in every module.

Is that possible?


  • I don't think it's "switched on" globally in the first place.
    Just make sure your server locale and database tables are all set to UTF-8 and you should be good to go as long as you use the Fuel & CodeIgniter Active Database functions for CRUD.

  • You have to change it on a per model basis because by default that model property is inherited from the MY_Model which by default is set to TRUE. For existing FUEL model's, you would need to extend them and use the module_overwrites in the fuel/application/config/MY_fuel_modules.php to map them to the updated model.

  • My DB ist setup correctly, but Umlauts or any other special characters are encoded (ü => ü). I don't think that's good. Content should go into the DB unchanged and be sanitized when outputted.

    It also makes problems with filters in the backend. Searching for "Glück", won't match "Glück", so I rather turn it off everywhere.

    Do you have a code example how to overwrite it? I have to admit, all the different places and variables to overwrite one or another thing is sometimes confusing :)

    Thank you!

  • Place your custom models in the fuel/application/models folder. You can extend extend native FUEL models and place them in that folder as well (e.g. My_pages_model).

    In your model, change your model's $auto_encode_entities property like so:

    public $auto_encode_entities = FALSE;

    Then, in the fuel/application/config/MY_fuel_modules.php, map the model to the module or overwrite it (as in the example below) with the model_name key:

    // Existing module
    $config['module_overwrites']['pages']['model_name'] = 'My_pages_model';
    // New module
    $config['module_overwrites']['my_module']['model_name'] = 'My_new_model';
Sign In or Register to comment.