Modifying a form value in form_fields() doesn't get saved

edited May 2014 in News & Announcements
Hi,

I simply want to use htmlspecialchars_decode on the content field value before the form is rendered, though this does not work:
function form_fields($values)
{
$fields = parent::form_fields($values);

if(!empty($values['content'])) {
$fields['content']['value'] = htmlspecialchars_decode($values['content']);
}

return $fields;
}

I need to do this as when I save a bunch of HTML in a field, it gets removed. How can I stop this from happening?

Thanks!

Comments

  • edited 9:39PM
    The reason why is because, it gets overwritten with a call to Form_builder::set_field_values() method which usually contains the values of the models find_one_array. You can specify an "edit_method" for you module in your MY_fuel_modules.php file which would run htmlspecialchars_decode on your content value however, it may be easier to use a "pre_process" function like so:
    $fields['content']['pre_process'] = 'htmlspecialchars_decode';
Sign In or Register to comment.