pagevariable gets converted from string to array


i have a problem with a automatic type conversion of a page variable. I created a new layout in my advanced module in the "MY_fuel_layouts" like this:

$config['layouts']['image'] = array(
'fields' => array(
'image' => array('type' => 'asset', 'label' => 'Image'),
'pos_size' => array('label' => 'Pos / Size', 'type' => 'textarea', 'represents' => 'string'),

In the Backend Page Edit Form the pos_size is rendered as a input field and if i write something in it is saved as a page variable with type "string" into the DB.

The Problem starts as i insert some serialized data via one of my controllers into page variable 'pos_size'.

$tempData['value'] = serialize($tempPos);

The next time i edit the page in the CMS after the insert the input field is populated with the serialized string correctly, but if i save the page it gets converted to a array in the fuel_page_variables table and the input field gets empty on reload.

Is there a way to strictly define the type of the page variable?


  • edited 7:49PM
    FUEL will automatically detect if it's a serialized/JSON data and decode it. Certain field types, such as the "template" field type need an array structure to render. you could try adding a pre_process parameter:
    'pos_size' => array('label' => 'Pos / Size', 'type' => 'textarea', 'represents' => 'string', 'pre_process' => 'serialize'),
Sign In or Register to comment.