Results 1 to 7 of 7

Thread: Test for uniqueness with hidden field

  1. #1
    New user
    Join Date
    08-19-09.
    Posts
    10

    Default Test for uniqueness with hidden field

    Hi,

    i'm currently using formauto along with the eventsattend extension. People log in and are then able to register for an event. Personal information (e.g. user id) is handed over by hidden formular fields that are set by insert-tags. To avoid double booking, it would be great to check for uniqueness by user id. However, it is not possible to choose a hidden field as basis for the uniqueness check. Is it possible to change this?

    Thank you so much for your great work,

    dan

  2. #2
    Experienced user
    Join Date
    06-11-09.
    Location
    Cape Town, South Africa
    Posts
    1,387

    Default Re: Test for uniqueness with hidden field

    its easy to allow hidden fields to be selected, but the purpose of having unique validation, is to provide the user with feedback that his submitted field is not unique, through an error message. Since the field is hidden, and cannot be changed by the user anyway, what purpose will it serve to check it for uniqueness? In other words, if its not unique, then what, because FormAuto will not submit the form, nor will it be possible for the user to do anything about it.

    Also hidden fields, do not generate validation errors, so nothing can be displayed. See the dilemma.

    I can suggest that you auto-complete the e-mail using the logged-in user, but then use javascript to disable the control to prevent it being edited.

  3. #3
    New user
    Join Date
    08-19-09.
    Posts
    10

    Default Re: Test for uniqueness with hidden field

    The purpose is to avoid double booking by the user. Thus, the user could get Feedback like "You are already registered for the event XYZ".

    Do you have a better idea to avoid double booking?

  4. #4
    Experienced user
    Join Date
    06-11-09.
    Location
    Cape Town, South Africa
    Posts
    1,387

    Default Re: Test for uniqueness with hidden field

    I already provided the way I currently use it, as e-mail only, which has to be unique anyway. I've only had a few instances with multiple bookings where people use their google addresses as well, but the organiser can pick those up quickly.

    The problem is that there is no way to provide the error message to the user. FormAuto integrates with the Form controls, there is no TL callback to write out an error message above/below the form, ONLY right next to the control (like if you forget to enter a value). The Hidden Widget in TL has no method that will write errors to the screen since its hidden -- so its impossible to do that at this stage. We have to write out an error next to a control that is visible.

  5. #5
    New user
    Join Date
    08-19-09.
    Posts
    10

    Default Re: Test for uniqueness with hidden field

    Thank you for your suggestion. However, as i'm not a Javascript-Geek - could you give me a hint how to prevent the auto-completed field from being edited?

  6. #6
    Experienced user
    Join Date
    06-11-09.
    Location
    Cape Town, South Africa
    Posts
    1,387

    Default Re: Test for uniqueness with hidden field

    Here is the JS code you need to use. Remember to replace the ID with the field ID value.
    You can simply include the text below as an HTML element in your form, so they stay together.

    Code:
    <script type="text/javascript">
    <![CDATA[//><!--
    document.getElementById("f21").disabled = true;
    //--><!]]>
    </script>

  7. #7
    Experienced user
    Join Date
    06-11-09.
    Location
    Cape Town, South Africa
    Posts
    1,387

    Default Re: Test for uniqueness with hidden field

    Hi budodan

    I've updated the FormAuto module to support Unique on Hidden Fields as you needed it, as I also needed it. It adds an error message to the TOP of the form using the TL_ERROR session variable. This will allow a hidden field to generate and error above the form. To ensure that everything works ok, you should complete the Hidden Fields LABEL as well, you can fake this by changing it temporarily to a text field, then complete the LABEL and then save, then change it back to HIDDEN and save again. The label is still stored even if its not visible and is retrieved to generate the label of the error field.

    This was a stroke of luck, because leo passes to the validate HOOK, even if the form doesn't have a validate function (like the HIDDEN field), so FormAuto can do the processing. Yah!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •