• Resolved IT Hertz

    (@it-hertz)


    I found this and wondered whether the capability has been added and I’m just doing it wrong or if it will be added in the near future: https://www.ads-software.com/support/topic/set-a-default-value-and-different-placeholder/

    I have a rather large, complex form with placeholders in some fields. I want the placeholders to show for new (unregistered) users but default values to prefill for logged-in (registered) users.

    I’m aware of tooltip plugins, but for this application I prefer to use placeholders.

    Is there a workaround other than using two separate forms, one for logged-in users and one for non-logged-in users?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Takayuki Miyoshi

    (@takayukister)

    but default values to prefill for logged-in (registered) users

    How do you achieve this?

    Thread Starter IT Hertz

    (@it-hertz)

    How do you achieve this?

    With the built-in tag function: https://contactform7.com/setting-default-values-to-the-logged-in-user/

    In this particular case, my client is a dance school. I use a single CF7 form to perform the following functions:
    Apply for site registration to access exclusive Parent Portal content
    Apply for school registration of their child(ren)
    Sort dancers by class & strip all but 2 highest levels (all others train free)
    Sign application form (sign the box or upload existing sig file)
    Create tuition order for the 2 highest levels (or single item if 1 dancer)
    Create separate WooCommerce account
    Send application emails to school staff; modified copy goes to applicant
    Send WC email of payment to bookkeeper; modded copy to applicant
    Copy all data to separate database plugin for review/revision by school staff

    My goal was to automate the process as much as possible, so all of the above is carried out with one click of the submit button. There’s a separate checkout page for making payments, of course.

    An example of how I use placeholders on my form is my Emergency Contact fields. I have two of them, because separating first and last names and splitting into separate meta data entries is better for filing/spreadsheet purposes. I use the same label for both, because long labels such as “Emergency Contact First Name” cause display issues (wraps, pushes fields down on mobile due to the field widths being reduced, etc.). It’s really messy looking. Hence, I use placeholders like so: [text* Emergency_Contact_First_Name placeholder "First Name"], same for Last Name field.

    It would be helpful to have conditional tags, where the default would override the placeholder in the case of a logged-in user, else the placeholder is used, like so: [text* Emergency_Contact_First_Name placeholder "First Name" default:user_emergency_contact_first]

    I have several other fields that guide the new user with placeholders. I really would rather not use hover tooltips for this particular form – they would also be pointless for logged-in users, so unless the tooltips are conditional, it would look odd presenting them to existing users who are already familiar with the form and whose data is prefilled to begin with.

    As mentioned before, I can create a duplicate form if need be, for the sole purpose of using placeholder tags, and use redirects for logged vs. non-logged users to take them to the appropriate form, but having two [almost] identical forms seems redundant and a waste of storage space.

    Btw, it would also be helpful to preset/prefill all other field types, such as calendar, dropdowns, etc. I haven’t checked whether this is already covered, but if default only prefills text fields, adding the other field types would be great.

    • This reply was modified 1 year, 3 months ago by IT Hertz. Reason: last paragraph
    Thread Starter IT Hertz

    (@it-hertz)

    It should be relatively simple. The plugin could check if the specified default data exists. If not (null), then use the placeholder and ignore the default tag parameter.

    Plugin Author Takayuki Miyoshi

    (@takayukister)

    It’s just that you have the wrong syntax in the tag.

    [text* Emergency_Contact_First_Name placeholder "First Name" default:user_emergency_contact_first]

    See How tags work

    Thread Starter IT Hertz

    (@it-hertz)

    After trying various ways, I see now. Default must come before placeholder in tag options. That does work.

    That’s not clear from your docs, as the table flow shows placeholder above/before default. And, since default doesn’t appear in your text example and placeholder doesn’t appear in your default example, I incorrectly assumed the table order indicated syntax/option order, but it’s reversed.

    Is it safe to assume that because the default option doesn’t appear in the table spec for date type that this is not currently available? And, because default is the item number/position with dropdowns, checkboxes and radios this means this selection is hard and cannot be pulled from the meta data (i.e., if I were to translate the meta data to an item number in functions.php it still can’t be passed to the field)? This would be helpful, as I use a lot of these field types in my form as well.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘placeholder and default in same tag’ is closed to new replies.