two blocks
// Fuel layout block
$block = new Fuel_block_layout('about_article_block');
$block->set_label('About article');
$block->add_field('title', array());
$block->add_field('anchor', array());
$block->add_field('content', array('type' =>'text'));
$block->add_field('social', array('label'=>'Social sharing','type' =>'checkbox', 'value'=>1));
$config['blocks']['about_article_block'] = $block;
$block = new Fuel_block_layout('about_related_article_block');
$block->set_label('About elated article');
$block->add_field('article_title', array('label'=>'Title'));
$block->add_field('article_link', array('label'=>'Link', 'ignore_representative' => TRUE));
$block->add_field('article_img', array('type' =>'asset','label'=>'Image',));
$config['blocks']['about_related_article_block'] = $block;
then i specify a layout with above blocks.
$layout = new Fuel_layout('about');
$layout->add_fields($common_fields);
$layout->add_fields(
array(
'banner'=>array('type'=>'asset'),
'banner_text'=>array('type'=>'text'),
'sections'=>array(
'type'=>'template',
'display_label'=>FALSE,
'label'=>'Sections',
'add_extra'=>FALSE,
'repeatable'=>TRUE,
'max'=>6,
'min'=>1,
'title_field'=>'block',
'fields'=>array(
'section'=>array('type'=>'section', 'value'=>'Section {num}'),
//'block'=>array('type'=>'block','folder'=>'sections'), if specify folder will only display blocks under that folder
'block'=>array('type'=>'block'),
),
),
'related_articles' => array('type' => 'fieldset', 'label' => 'Related Articles', 'class' => 'tab'),
'r_articles'=>array(
'type'=>'template',
'display_label'=>FALSE,
'label'=>'Related Articles',
'add_extra'=>FALSE,
'repeatable'=>TRUE,
'max'=>2,
'min'=>1,
'title_field'=>'article',
'fields'=>array(
'section'=>array('type'=>'section', 'value'=>'Related Article {num}'),
'block'=>array('type'=>'block', 'block_name'=>'about_related_article_block','display_label'=>FALSE),
),
),
)
);
please note of 'block'=>array('type'=>'block', 'block_name'=>'about_related_article_block','display_label'=>FALSE), four lines above, once i set the block_name to force the article tab to show only the related field of about_related_article_block, everything go haywire.
What is happening now is it does dislay all the fields. however if i save it. It will auto loop the fields section up to 4 times despite the max set to 2 and i did not add any repeatable section for this tab.
but if i removed block_name to change back to drop down select style, there will NOT have any problem when saved.
very weird behavior to me, any helps?
Comments
'context' => 'r_articles[0][block]'
'block'=>array('type'=>'block', 'block_name'=>'about_related_article_block','display_label'=>FALSE, 'context' => 'r_articles[0][block]'),
$block = new Fuel_block_layout('whatsnew_article_block');
$block->set_label('Whatsnew');
$block->add_field('title', array('label'=>'Title'));
$block->add_field('description', array('label'=>'Description'));
$block->add_field('link', array('label'=>'Link','ignore_representative' => TRUE));
$block->add_field('tag', array('label'=>'Tags', 'type'=>'checkbox'));
$block->add_field('cover_img', array('type' =>'asset','ignore_representative' => TRUE));
$config['blocks']['whatsnew_article_block'] = $block;
$layout->add_fields(
array(
'whatsnew'=>array(
'type'=>'template',
'display_label'=>FALSE,
'label'=>'Sections',
'add_extra'=>FALSE,
'repeatable'=>TRUE,
'min'=>1,
'title_field'=>'block',
'fields'=>array(
'section'=>array('type'=>'section', 'value'=>'Section {num}'),
'block'=>array('type'=>'block','block_name'=>'whatsnew_article_block','display_label'=>FALSE, 'context' => 'whatsnew[0]block]'),
),
),
)
);
$layout->set_label('Whats New Home');
$config['layouts']['whatsnew_home'] = $layout;
the "Asset" types will not shown ( only show normal input text field with upload and select button) if include the 'block_name'=>'whatsnew_article_block','display_label'=>FALSE, 'context' => 'whatsnew[0]block]'
i done some check and discover that the id of the "asset"field will be same as the repeated block "asset" field if click "add more", and the styles are same too
And if i remove 'block_name'=>'whatsnew_article_block','display_label'=>FALSE, 'context' => 'whatsnew[0]block]' and allow the drop down select the block, asset field will shown without any problem.
https://github.com/daylightstudio/FUEL-CMS/commit/c315747b4383807424207bee89af7301485e9af6
$block->add_field('tag', array('label'=>'Tags', 'type'=>'multi','mode'=>'checkbox','options'=>$tag_options,'default'=>array()));
when i saved first block and click add another, the multi checkbox of tag already checked with values from first block, it does not reset to empty.
$(document).on('click', '.' + options.addButtonClass, function(e){
e.preventDefault();
e.stopImmediatePropagation();
alert('data');
});
no alert when i click the button
1. Go to the fuel/modules/fuel/config/fuel.php file and uncomment all the js files currently commented out in the $config['fuel_javascript']. Then comment out the 'fuel' => 'fuel/fuel.min'.
2. Go to fuel/build and it will recompile the CSS and JS files (will take a few seconds).