Jump to content

Global Field for Validation before save


Recommended Posts

Hi friends !

I'm intend to create a very complex website for a insurance company that will include very complex calculations and validation rules.

To achieve this, I've created a global field called "validation (textarea)", where I want to write php scripts for validation in the style Hanna Code. So, every single record that I will save (backend and frontend) should call the validation script before doing that.  

Is it possible with PW ?  Could you help me with a roadmap ?

Thank you all !


Link to comment
Share on other sites

This is certainly possible, but should most likely not be done as part of the admin backend, but via modules. There are various point where you can hook into the core functions to inject your validation rules. The most obvious would be Inputfield(Name)::processInput or Pages::save. 

  • 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

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By daniel_puehringer
      Hi community, thanks for the great work you do 🙂

      I´m looking for a global field which can be used in the footer and has only one instance for all pages. So I´m kind of looking for "One field to rule them all".
      Reason for my question: The website I´m currently building has one footer for all pages. The content of the footer should be dynamic - therefore I made a global field which is automatically inserted into each page.
      Problem: if I want to change something in the footer, I have to do it for all fields, because each field has it´s own instance.

      Question: is it possible to have one global field in which changes the content for the footer of all pages?

      In most CMS Systems a simple solution to this is often impossible, I hope that processwire is different 🙂

      All the best,
    • By Andreas Augustin
      I want to build a custom validator on my multilang site.
      I added following hook, but I get only the default language value. How can I access the values of the other languages?
      public function init() { $this->addHookAfter("InputfieldTextarea::processInput", $this, "validateShortlinks"); } public function validateShortlinks($event) { $field = $event->object; $text = $field->value; // only the default language, how can I get the other languages? }  
    • By waheed
      Hi, Coming from a background of WP I'm very new to PW (this is my very first project), but so far it has been very easy to learn. Currently I'm developing an intranet webapp to my school. I would like the "school grades" to be added as pages without any field in it, except "title" and "name". I would like the "title" to hold only numbers (optionally min:1 & max:10) and non-repeating (pages with same title cannot be added). Is this possible to be done, if so how? (Pls, try not to guide me towards a premium module, we run on a small budget)
    • By ridgedale
      I was wondering if anyone has successfully integrated Securimage with Processwire 3.
      I've tried the suggested fixes posted here, but I haven't managed to get the captcha image to display. This might be because the instructions relate to Processwire version 2.x where I am working with version 3.
      Any ideas/steps what to do would be appreciated.
    • By modifiedcontent
      Is there a built-in way in PW to do email confirmation/validation?
      Someone signs up or does something with an email address; the system sends an email with a confirmation link to make sure the user actually owns the address.
      pwFoo and justb3a both use a double opt-in (?) confirmation link in their modules, but I think they use different methods? I can't figure out how they do it. Is there a recommended way? A quick, easy way?
      I am looking into how to put this together. I would need tables in the database for a validation code, generated at signup, and a true/false for account activation. Those would be two fields in the signup template/page, correct?
      But they would have to be added to the "user template"? Confused... I thnk this post explains it.
      Ryan in that thread also points to a built-in PW way to generate a validation code.
  • Create New...