Jump to content

Problem with category fombuilder module prestashop


Recommended Posts

Im trying to create module that allows me to add categoryTree in category form, but I came across a problem. I don't know how to make inputs selected by default when creating hookActionCategoryFormBuilderModifier. Here is my code:

public function hookActionCategoryFormBuilderModifier(array $params) {
    $formBuilder = $params['form_builder'];
    $formBuilder->add('my_module', ChoiceCategoriesTreeType::class, array(
        'label' => 'test',
        'list' => Category::getNestedCategories(Category::getRootCategory()->id, $this->languageId, false),
        'multiple' => true,

    ));
}

I've benn trying to do something like this, but it doesn't work:

    $params['data']['my_module'][2] = true;
    $formBuilder->setData($params['data']);

How can I make inputs selected by default? Thank you in advance for help.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...