Skip to content

Commit

Permalink
Merge pull request #135 formatFieldMultiselectForFront : doesn't chec…
Browse files Browse the repository at this point in the history
…k against choices list for front: good for performances
  • Loading branch information
jf-viguier authored Sep 1, 2023
2 parents 4512aeb + ad76d22 commit 8fea098
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
10 changes: 4 additions & 6 deletions classes/PrettyBlocksModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -660,11 +660,9 @@ public static function getBlocksAvailable()
$data[0] = $data;
}
foreach ($data as $block) {
if (!empty($block['code'])) {
$blocks[$block['code']] = $block;
// formatted for LeftPanel.vue
$blocks[$block['code']]['formatted'] = self::formatBlock($block);
}
$blocks[$block['code']] = $block;
// formatted for LeftPanel.vue
$blocks[$block['code']]['formatted'] = self::formatBlock($block);
}
}

Expand All @@ -686,7 +684,7 @@ private static function formatBlock($block)
$formatted['icon'] = $block['icon'] ?? 'PhotographIcon';
$formatted['icon_path'] = $block['icon_path'] ?? '';
$formatted['module'] = $block['code']; // todo register module name
$formatted['title'] = $block['name'] ?? '';
$formatted['title'] = $block['name'];
// dump($block);

// if nameFrom params is present
Expand Down
8 changes: 7 additions & 1 deletion classes/prettyblocks/core/PrettyBlocksField.php
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,13 @@ private function formatFieldSelect()
*/
private function formatFieldMultiselectForFront()
{
return $this->formatFieldMultiselect();
if (is_array($this->value)) {
return $this->value;
}
// if value doesn't exists in DB and new value is not set return default value
if ($this->force_default_value && isset($this->field['default'])) {
return $this->field['default'];
}
}

/**
Expand Down

0 comments on commit 8fea098

Please sign in to comment.