Jump to content

PS 1.7.8.6 - Help accessing the admin product formbuilder instance


Recommended Posts

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

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

  • Like 1
Link to comment
Share on other sites

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 by Mpix (see edit history)
  • Like 1
Link to comment
Share on other sites

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.

  • Like 1
Link to comment
Share on other sites

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!

  • Like 1
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...