Note the upgraded forum! If you are experiencing issues logging in, you may need to reset your password which should send an email. If the email doesn't arrive, be sure to check your spam folder just in case.

No data in template block fields when editing record in simple module

edited April 2015 in Bug Reports
in my simple module I got this field:
public $serialized_fields = array('content'); $fields['content'] = array( 'display_label' => false, 'add_extra' => FALSE, 'init_display' => 'all', 'dblclick' => 'toggle', 'repeatable' => TRUE, 'style' => 'width: 680px;', 'type' => 'template', 'label' => 'Content', 'title_field' => 'sections', 'fields' => array( 'sections' => array('type' => 'section', 'label' => 'Block <span class="num">{num}</span>'), 'block' => array('type' => 'block', 'folder' => 'landing', 'label' => 'Block') ) );
when I'm saving new record, data saves in database and in view page I can see content of that field, but in admin when I edit this record, this template field has all blocks but the value of this blocks is empty...
I'm using same template field in MY_fuel_layouts.php and in simple module, in layouts every thing works fine, values are saving and I can see them when editing page, in simple module I can see only empty fields... What can cause this issue?


  • edited 2:20AM
    If you are using the block field in a module, you'll need to specify the "module" parameter for your block field.
  • edited April 2015
    I tried to specify a parameter, but have no effekt, maybe I did something wrong:
    $fields['content'] = array( 'type' => 'template', ... 'fields' => array( 'sections' => array('type' => 'section', 'label' => 'Block <span class="num">{num}</span>'), 'block' => array('type' => 'block', 'folder' => 'landing', 'label' => 'Block', 'module' => 'app') ) ...
    So in My_fuel_layouts.php I have some defined Fuel_block_layouts that I can use in creating pages and it workes fine, I want to use those blocks in my simple module, when I create a new record in module I can see and use those blocks, when I save that record, data saves in database like JSON and it appears in view file but in admin page those bloks become empty...
  • edited 2:20AM
    For the module parameter, use the name of the simple module you want to save it to (e.g. news)
  • edited April 2015
    I changed 'module' => 'app' to 'module' => 'news' and in my news module and still got this problem...
    However, if I set $model = 'news_model' in class Fuel_block_layout (fuel/libraries/Fuel_layouts.php line 1307) it worked!
    Maybe I should define module somewhere else?
  • edited 2:20AM
    My bad on that. You are correct (I just did this the other day so should have remembered). You need to define it on the layout itself what model you want to set.
  • edited 2:20AM
    Yes, thanks David!
    I use this in My_fuel_layouts.php:
    $text_block = new Fuel_block_layout('news_item'); $text_block->set_model('news_model');
    and it worked!
  • edited 2:20AM
    Please advise me what is the best way to use a single block layout in several modules?
  • edited 2:20AM
    Do you mean you need to have a single block layout that has a different model to save to? If so, block layouts only support the ability to save to the set model on the layout.
  • edited 2:20AM
    Yes, I have to use a lot of blocks in modules and certain pages that are repeatable ...
    So will have to produce blocks.
Sign In or Register to comment.