Mpix Posted July 1, 2022 Share Posted July 1, 2022 Hello, Noob here. I'm developing a module where I need to alter the formbuilder instance for the product page in the BO. The one used in PrestaShopBundle\Controller\Admin\ProductController::createProductForm . It doesn't seem to have a "FormBuilderModifier" hook, so I am stuck. Any idea of a method I could use to access it from a module hook? Thank you very much in advance! Link to comment Share on other sites More sharing options...
knacky Posted July 3, 2022 Share Posted July 3, 2022 It doesn't work that way. It is necessary to override the twig template. The product page in the admin contains several twig templates. ./src/PrestaShopBundle/Resources/views/Admin/Product/*.* E.g. /modules/your_module/views/PrestaShop/Admin/Product/Panels/essentials.html.twig 1 Link to comment Share on other sites More sharing options...
Mpix Posted July 3, 2022 Author Share Posted July 3, 2022 Thank you! That's a great help and it should help with a big part of the changes I have to do make. 1 Link to comment Share on other sites More sharing options...
knacky Posted July 3, 2022 Share Posted July 3, 2022 I will be happy to help if you write me more information. 1 1 Link to comment Share on other sites More sharing options...
Mpix Posted July 4, 2022 Author Share Posted July 4, 2022 (edited) Thanks, but I think you gave me the tip I needed already! For those stumbling here through google with the same question: my scope was altering/hiding some steps and adding several others, for a customer with a very extended product. Ie: their prices are generated from a formula based on various parameters, so the price tab "existing" could lead to accidental overwriting. MANY, MANY new switches and fields. "displayAdminProductsExtra" is too hidden away, we aimed at more visual clarity for the client's large team. On top of Knacky's suggestion, I'm attempting to override 'PrestaShopBundle\Controller\Admin\ProductController' from the module's 'config/services.xml' file. From there I should be able to: override createFormBuilder() to add my data/steps change the main template through the @Template annotation of formAction() if needed use Knacky's method to improve the other tabs \o/ Good luck. Edited July 4, 2022 by Mpix (see edit history) 1 Link to comment Share on other sites More sharing options...
knacky Posted July 4, 2022 Share Posted July 4, 2022 I prefer to use javascript and ajax when programming more complex product configuration modules. Each element has its own id and I add a custom div to it etc. It's faster and everything can be saved to the database immediately after clicking, selecting, etc. It may happen that some module already overrides the twig template and then the next override will not work. 1 Link to comment Share on other sites More sharing options...
Mpix Posted July 4, 2022 Author Share Posted July 4, 2022 It's a great approach. I would in other circumstances (or stick to the hook), but this blessed project is 99% custom-made features which allows for full freedom, so I might as well get some Symfony in! 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now