You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The actual request is to make it possible to use Gutenberg blocks in complex fields. If I understand correctly, this would require the functionality of set_render_callback to be applied on the field level, right? Something like code below:
Block::make('sample_grid', 'Grid Layout')
->add_tab('Tiles', [
Field::make('complex', 'grid_tiles', 'Grid Tiles')
->add_fields([])
->set_min(2)
->set_collapsed(true)
->set_inner_blocks(true)
->set_render_callback(function ($value, $attributes, $inner_blocks) {
print'<div class="tile">' . $inner_blocks . '</div>';
})
])
->add_tab('Options', [
Field::make('text', 'columns_count', 'Number of columns per row')
->set_default_value(2)
->set_attribute('min', 2)
->set_attribute('max', 6),
Field::make('text', 'grid_gap', 'Gap (in pixels) between columns and rows')
->set_attribute('min', 0)
->set_default_value(24),
])
->set_description("Grid block")
->set_render_callback(function ($fields, $attributes) {
$classes = ['grid','cols-'.$fields['columns_count']];
print'<div class="'.implode('',$classes).'" style="--gap: '.$fields['grid_gap'].'px">';
foreach($fields['grid_tiles'] as$item {
printcrb_render_field($item); // new function to present rendered field
}
print'</div>';
});
I really hope it makes sense. Thank you for your awesome plugin anyways!
The text was updated successfully, but these errors were encountered:
Version
Feature Request/Suggestion
The actual request is to make it possible to use Gutenberg blocks in complex fields. If I understand correctly, this would require the functionality of
set_render_callback
to be applied on the field level, right? Something like code below:I really hope it makes sense. Thank you for your awesome plugin anyways!
The text was updated successfully, but these errors were encountered: