Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Tony 104 posts 162 karma points
    Mar 31, 2015 @ 14:05
    Tony
    1

    Forms custom validation

    Not quite sure why this was released in its current state, there seems to be so much missing (or the documentation isnt there)

     

    In contour we have lots of custom validation on our forms, ie to check emails were not in use etc.. and to do this we used the FormRenderController_FormValidate in the ApplicationEventHandler. However this seems to have dissapeared? 

     

    Does anyone know how to use custom validation on these forms? Seems like an essentail bit of functionality to me.??

  • Dennis Aaen 4457 posts 17969 karma points admin hq c-trib
    Mar 31, 2015 @ 14:09
    Dennis Aaen
    0

    Hi Tony,

    The documentation for the Umbraco Forms, can be found here: https://our.umbraco.org/documentation/Products/UmbracoForms/

    Hope this can help you.

    /Dennis

  • Tim Geyssens 6562 posts 15373 karma points MVP 2x c-trib
    Mar 31, 2015 @ 14:09
    Tim Geyssens
    0

    Yeah was gone but will be back in v4.0.3, you can already upgrade to a nightly http://nightly.umbraco.org/UmbracoForms/nightlies/

  • Tony 104 posts 162 karma points
    Mar 31, 2015 @ 14:39
    Tony
    0

    Ah fantastic, will save countless hours rebuilding :)

  • Tim Geyssens 6562 posts 15373 karma points MVP 2x c-trib
    Mar 31, 2015 @ 14:52
    Tim Geyssens
    0

    so  in Forms it will be the event Umbraco.Forms.Web.Controllers.UmbracoFormsController.FormValidate

  • Tony 104 posts 162 karma points
    Mar 31, 2015 @ 15:04
    Tony
    0

    Great, I was looking in that controller for a validation event previously, glad I was at least in the right area :)

  • Tony 104 posts 162 karma points
    Apr 01, 2015 @ 13:50
    Tony
    0

    How do I get the validation error messages to appear? Im adding them to the Model error collection as I did with contour but nothing is showing? 

     

    private void FormRenderController_FormValidate(object sender, FormValidationEventArgs e)
    {
               if (e.Form.Name == FormTitles.ChoosePassword || e.Form.Name == FormTitles.ChangePassword)
               {
                   var s = sender as Controller;
                   if (s != null)
                  {
                       Field passwordField = e.Form.AllFields.SingleOrDefault(f => f.Caption == Captions.NewPassword);
                       Field confirmPasswordField = e.Form.AllFields.SingleOrDefault(f => f.Caption == Captions.ConfirmNewPassword);

                        if (passwordField != null && confirmPasswordField != null)
                       {
                           string password = e.Context.Request[passwordField.Id.ToString()];
                           string confirmPassword = e.Context.Request[confirmPasswordField.Id.ToString()];
                           if (password != confirmPassword)
                           {
    s.ModelState.AddModelError(confirmPasswordField.Id.ToString(), ErrorMessages.PasswordMismatch);
                           }
                       }
                   }
               }
    }
  • Tim Geyssens 6562 posts 15373 karma points MVP 2x c-trib
    Apr 01, 2015 @ 13:52
    Tim Geyssens
    0

    That should do the trick, will try to reproduce

  • Tim Geyssens 6562 posts 15373 karma points MVP 2x c-trib
    Apr 02, 2015 @ 10:36
    Tim Geyssens
    0

    Yeah just tested and it works like expected, are you sure the code is getting hit, so that your form captions are the ones you are checking for?

  • Tim Geyssens 6562 posts 15373 karma points MVP 2x c-trib
    Apr 02, 2015 @ 11:02
    Tim Geyssens
    0

    Just tested the same setup and it works so I think it will have to do with the check on captions

  • Tony 104 posts 162 karma points
    Apr 02, 2015 @ 16:51
    Tony
    0

    Its hitting the code and adding the error to the collection but there is no validation showing, I couldnt see it in the source but I can take another look

  • Tony 104 posts 162 karma points
    Apr 23, 2015 @ 12:05
    Tony
    0

    Sorry for the slow response, Im back on this and cannot see the errors appear in the source code which is generated after the form is submitted, its hitting the validation and adding the errors to the model errors correctly? The standard mandatory validation on thr form itself works fine, just not the custom ones?

  • Tony 104 posts 162 karma points
    Apr 23, 2015 @ 13:01
    Tony
    0

    The standard forms validation is client side so works fine, but when the page is submitted it hits teh custom validation and adds the erro rmessages but does not reload the page which I assume is the reason it doesnt show teh error in the updated model?

  • Simon 692 posts 1068 karma points
    Dec 23, 2015 @ 14:44
    Simon
    0

    Hi Tony,

    First all, Happy Christmas.

    Can I ask you how have you solved the issue you was encountering, regarding the custom validation error messages?

    Thank you very much.

  • Simon 692 posts 1068 karma points
    Dec 27, 2015 @ 11:37
    Simon
    0

    Hi Tony,

    How have you solved the issue please?

    Thank you.

  • Simon 692 posts 1068 karma points
    Sep 18, 2015 @ 09:31
    Simon
    0

    Hi Guys,

    Anyone can help me?

    I am trying to do a custom validation for Umbraco forms but I do not have FormValidate:

    Umbraco.Forms.Web.Controllers.UmbracoFormsController.FormValidate

    FormValidate does not exist in UmbracoFormsController.

    Any help please?

    Kind Regards

  • Simon 692 posts 1068 karma points
    Sep 18, 2015 @ 11:41
    Simon
    0
     'Umbraco.Forms.Web.Controllers.UmbracoFormsController' does not contain a definition for 'FormValidate'
    
  • Simon 692 posts 1068 karma points
    Dec 21, 2015 @ 21:06
    Simon
    0

    Hi Tony or someone,

    Have you got a solution for this regarding to show the validation error please, because like yours, I cannot see an errors after the custom validation?

    Thank you :)

Please Sign in or register to post replies

Write your reply to:

Draft