feat(main): Add FAQ accordion
This commit is contained in:
@@ -4,6 +4,7 @@ namespace Websmid\CustomHtml\Form\DataProvider;
|
||||
|
||||
use PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataProvider\FormDataProviderInterface;
|
||||
use Websmid\CustomHtml\Model\CustomHtmlBlock;
|
||||
use Websmid\CustomHtml\Model\CustomHtmlFaq;
|
||||
use Validate;
|
||||
|
||||
final class CustomHtmlBlockDataProvider implements FormDataProviderInterface
|
||||
@@ -19,8 +20,10 @@ final class CustomHtmlBlockDataProvider implements FormDataProviderInterface
|
||||
return [
|
||||
'id_ws_customhtml_group' => (int) $block->id_ws_customhtml_group,
|
||||
'title' => $block->title,
|
||||
'type' => $block->type,
|
||||
'show_title' => (bool) $block->show_title,
|
||||
'content' => $block->content,
|
||||
'faqs' => $this->loadFaqs((int) $id),
|
||||
'active' => (bool) $block->active,
|
||||
];
|
||||
}
|
||||
@@ -30,9 +33,21 @@ final class CustomHtmlBlockDataProvider implements FormDataProviderInterface
|
||||
return [
|
||||
'id_ws_customhtml_group' => 0,
|
||||
'title' => '',
|
||||
'type' => 'html',
|
||||
'show_title' => false,
|
||||
'content' => '',
|
||||
'faqs' => [],
|
||||
'active' => true,
|
||||
];
|
||||
}
|
||||
|
||||
private function loadFaqs(int $idBlock): array
|
||||
{
|
||||
return array_map(static function (array $faq) {
|
||||
return [
|
||||
'question' => $faq['question'],
|
||||
'answer' => $faq['answer'],
|
||||
];
|
||||
}, CustomHtmlFaq::getByBlockId($idBlock));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user