Announcement

Collapse
No announcement yet.

web-to-lead form, not requiered url field

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • web-to-lead form, not requiered url field

    Hi,
    on a web-to-lead form, have a url input, and this field is not requiered on our form, so user may leave it empty.
    If the user inputs url, form is working as expected so we get the data on crm, but as field is not requiered and the user leave it empty we get error:

    field: "url_field_name"
    type: "valid"
    label: "validationFailure"​
    scope: null

    Using js we can set if input is empty - set value to a valid url, but we do not want this. ​​​​​​​Tried value="", value="None" and value=null but doesn't seem to work.
    On Lead entity, url field it is also set as not required.

    Form was working normal couple months ago, don't know when stopped. Seems it's an espo bug.

    Thanks

  • #2
    Hi,

    https://github.com/espocrm/espocrm/b...rlType.php#L61
    https://github.com/espocrm/espocrm/b...terns.json#L32

    here the response of my friend (regex is complicate for me) :

    question : if a empty value is send to the above regex .. is valid or not ?

    response :

    If an empty value is passed to the regular expression I provided, it will not be considered a valid match. This is because the regular expression requires at least one character to be present in the URL, and the empty string does not contain any characters.

    However, if you want to allow empty values to be considered valid, you can modify the regular expression to allow for an optional URL. To do this, you can remove the "+" at the end of the "[a-zA-Z0-9%\.\/\?\:@\-_=#$!+*\(\)',]" part of the regular expression, like this:

    ((a-zA-Z0-9)\\:\\/\\/)?[a-zA-Z0-9%\\.\\/\\?\\:@\\-_=#$!+*\\(\\)',]*\\.([a-zA-Z0-9%\\&\\.\\/\\?\\:@\\-_=#$!+*\\(\\)',])*

    With this modification, the regular expression will match an empty string as a valid URL.

    I hope this helps. Let me know if you have any further questions.



    i prefer change this, more simple for me:

    if ($value === null || empty($value) ) {
    return true;
    }

    to try.

    edit : oups, it's in bug section .. :s
    Last edited by item; 12-22-2022, 08:28 PM.

    Comment


    • #3
      Oh, I'm sorry. I was not really sure to post it as a bug or in developer help. But as in the Lead entity you can create record without enter any data (empty) in a url field when it's not required, but not when it's posted by web-to-lead form, I consider it more like a bug.
      Thanks for your reply, will try and get back

      Comment


    • #4
      Good morning item, yes your short solution worked fine.
      Is this solution update safe?

      I still consider it like a bug for two reasons.
      First because forms was working fine and seems they changed code so our forms left non working for months untill we realized it and
      second because as by default you are able to create record with empty url field, so you expect the same through web-to-lead form (and why not?).

      Will not remove this post, for future use. This can help others too but moderators can still remove it.

      Thank you!!

      Comment


      • #5
        Try sending null instead of empty string.

        Comment


        • #6
          Originally posted by yuri View Post
          Try sending null instead of empty string.
          If you read first post I already tried it, got the same error

          Comment


          • #7
            Well, I tried with empty string and got the same error. I tried null, and it worked.

            Comment


            • #8
              Originally posted by yuri View Post
              Well, I tried with empty string and got the same error. I tried null, and it worked.
              if we do item suggestion (|| empty($value)), it works both ways, using value "" or null,
              without this modification does not work in any way (except if user pass a url in the corresponding field in the web-to-lead form).

              Also, we have to comment this line <<if (this.readyState == XMLHttpRequest.DONE && this.status == 200)>>, else we get the data but the user does not get the "received message".
              Little strange

              Comment

            Working...
            X