Drupal Answers Asked by Drii7 on December 31, 2021
I need this in Rules:
When a node is being created (before the node is saved), and certain conditions are true, the user can’t create the node, and an error message appears instead.
I have a rule that is working, and the error message is displaying. But the node is still created.
Is there a way to prevent node creation in rules?
Note:
I’m using Drupal 7. I selected the Action “Show error message” directly on rules.
Out-of-the Rules module-box, I think there is no solution to "prevent node creation in rules?" (as in your question). However, without using custom code and custom PHP in your Rules conditions or actions and without deleting the node after it got created, you may get it to work if you also use the Rules Forms Support module.
More details about Rules Forms Support (from its project page):
Rules Forms Support provides a Rules based method for controlling forms and their elements. The module can be used to alter any form provided by Drupal core or contributed modules. Change element titles, descriptions, weights, and more, or validate form data and set form errors. Rules forms saves time and cost by affording site builders the ability to monitor and alter forms without the need to implement a custom module.
For help getting started with Rules Forms Support, please see the module documentation.
Features
- Activate events for form creation, validation, and submission on a form-by-form basis.
- Target individual form elements or the entire form in conditions and actions.
- Manipulate the attributes of a form element like title, description, weight, and more.
- Validate the values of form elements during form validation.
- Set form errors when rule-based validation fails.
- Redirect users to a different page upon viewing or submitting a form.
- Examine the attributes of elements in active forms with the element inspection tool.
Especially the "Set form errors when rule-based validation fails" should help to address your question.
More details about how to use this module can be found in the community documentation "Altering & validating forms".
Answered by Pierre.Vriens on December 31, 2021
I solved this by using the drupal_goto function.
Answered by Drii7 on December 31, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP