Need help with module validation



  • Hey everyone,

    Could someone please help me here, I have created a module that will install a Manufacturer logo carousel. You can see the module in action here:
    https://www.orren-life.com

    I am however struggling to validate the module config form and display any errors. I used the PS module generator to get a module template, however I did not see any form validation code in there.

    Does anyone have validation code examples for me? I have looked at other modules, however none of these are written like the generator creates teh functions.

    Yup a you guessed, I don’t have much experience in OOP PHP

    Would appreciate any help.



  • Check getContent() function.
    You are probably calling postProcess() in that function and than outputing the renderForm.
    So you can have what ever you need either in the postProcess or in the getContent.



  • Thanks,

    I had a look at the generator files that were created (I used the generic Module template as I don’t understand what the service module would be for).

    So essentially the getContent refers to renderForm, which then calls getConfigForm. Then there is getConfigFormValues and finally the postProcess.

    I was trying to write the validation script in there. Which I successfully did do, however I was unable to output the values of the error message, when it found the error. So all it was doing is refreshing the form and imputing default values instead of showing the error.



  • You can use build in function $this->displayError('MY ERROR TEXT') to add errors



  • Great thanks, Ill give it a quick try


Log in to reply
 

Looks like your connection to thirty bees forum was lost, please wait while we try to reconnect.