Book Image

PrestaShop Module Development

By : Fabien Serny
Book Image

PrestaShop Module Development

By: Fabien Serny

Overview of this book

Table of Contents (19 chapters)
PrestaShop Module Development
About the Author
About the Reviewers

Adding a callback to options

One last method I want to introduce you to is onClickOption. This method will permit you to set the JavaScript OnClick trigger on the module's action buttons.

Here are the different action buttons that are compliant with the onClickOption method:

You are probably wondering when we should use the onClickOption method.

This method allows many possibilities. For example, in the case of our module, when the merchant uninstalls the module, it automatically drops the table of comments. When the merchant decides to reinstall the module, he won't retrieve the old comments.

Clicking the uninstall button by mistake is possible. With this method, we can display a confirmation box to ask the merchant whether he is really sure about performing this action.

To do so, you do not need to attach your module to any hook. Just add the following method to your module's main class:

public function onClickOption($type, $href = false)

The $type string contains keyword matching with the...