From b0c2c8b37eaa697212b62f8ef30bd6afe8b3687c Mon Sep 17 00:00:00 2001 From: shariquerik Date: Tue, 3 Aug 2021 13:53:53 +0530 Subject: [PATCH 1/2] docs: Docs for Custom Webform Context hook --- .../www/docs/user/en/python-api/hooks.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/frappe_docs/www/docs/user/en/python-api/hooks.md b/frappe_docs/www/docs/user/en/python-api/hooks.md index 45c6e59c..ac5944a7 100644 --- a/frappe_docs/www/docs/user/en/python-api/hooks.md +++ b/frappe_docs/www/docs/user/en/python-api/hooks.md @@ -433,6 +433,23 @@ The above configuration will render `/not_found` when a 404 is occurred. It is upto you to implement the template `www/not_found.html` and controller `www/not_found.py`. +## Custom Web Form Context + +When a Web Form is created using non custom doctype, we can get the context from doctype's module but for Web Form using custom doctype you cannot get the context since custom doctype don't have modules, you can use this hook to create a context for Custom Web Form. + +**app/hooks.py** +```py +get_list_context_for_custom_webform = "app.webform.get_list_context_for_custom_webform" +``` + +**app/webform.py** +```py +def get_list_context_for_custom_webform(): + return { + "get_list": get_transaction_list_for_custom_webform + } +``` + ## Default Homepage Homepage is the page which is rendered when you visit the root URL (`/`) of your From f7edd1d2a9646874d412e335fd9898fe3dcda906 Mon Sep 17 00:00:00 2001 From: Shariq Ansari <30859809+shariquerik@users.noreply.github.com> Date: Tue, 7 Sep 2021 11:14:16 +0530 Subject: [PATCH 2/2] Updating name for the hook --- frappe_docs/www/docs/user/en/python-api/hooks.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/frappe_docs/www/docs/user/en/python-api/hooks.md b/frappe_docs/www/docs/user/en/python-api/hooks.md index ac5944a7..3fe2f982 100644 --- a/frappe_docs/www/docs/user/en/python-api/hooks.md +++ b/frappe_docs/www/docs/user/en/python-api/hooks.md @@ -439,14 +439,14 @@ When a Web Form is created using non custom doctype, we can get the context from **app/hooks.py** ```py -get_list_context_for_custom_webform = "app.webform.get_list_context_for_custom_webform" +webform_list_context = "app.webform.get_webform_list_context" ``` **app/webform.py** ```py -def get_list_context_for_custom_webform(): +def get_webform_list_context(): return { - "get_list": get_transaction_list_for_custom_webform + "get_list": get_webform_transaction_list } ```