Re: Making Form Fields Read Only

Dan_Stevens_
Level 10 - Champion Alumni

Re: Making Form Fields Read Only

Justin provided an update here: https://nation.marketo.com/ideas/7175#comment-32731

SanfordWhiteman
Level 10 - Community Moderator

Re: Making Form Fields Read Only

So does this mean we need to create yet another template each and every time we want to extend the functionality of forms on our LPs?

I definitely wouldn't say that!

I always include custom form behaviors in external <script> tags, then enable and disable them using mktoBoolean variables. 

In many cases the behaviors are self-enabling, that is, if they only pertain to a given form ID then they'll be ignored for other forms, or if they only pertain to a given field they'll be skipped over if that field doesn't exist.

Amy_Lepre
Level 7

Re: Making Form Fields Read Only

Hi Chris,

Here's our use case:

We have a distributor network that sells our line of products. When leads that we've identified as belonging to our distributors come to our website and/or landing pages and generate enough activity to push their lead score over a certain threshold, we send the distributor an alert with the lead information and activity. We then ask them to provide feedback on the lead by means of a link in the email that contains a querystring with token values to populate the form fields in the landing page. We don't want the distributors to change the lead information, just want it to display so they can see they're providing feedback on the right person. I don't believe (trust) that the token on the landing page would work since the distributor's own cookied information may show instead of the lead's information. I'm certainly open to other ideas, but am going to take a look at what Sanford provided below to see if that works for me.

Thanks for your response!

SanfordWhiteman
Level 10 - Community Moderator

Re: Making Form Fields Read Only

I don't believe (trust) that the token on the landing page would work since the distributor's own cookied information may show instead of the lead's information.

You're correct about this.

But what you didn't explain before is that the fields are being filled from the query string. In Forms (1.0 and 2.0) this isn't native behavior because only hidden fields are filled from the query. Therefore you need to parse the query string as well.  I added that functionality to expanded CodePen. You can use uri.js as included in the HTML pane here: MktoForms2 :: Lock URL-Filled Fields

My_Nguyen
Level 2

Re: Making Form Fields Read Only

I came across an issue where a plus symbol in someone's email address causes this to input an invalid email in the email field because it turns into a space. Do you know of a way to fix that?

SanfordWhiteman
Level 10 - Community Moderator

Re: Making Form Fields Read Only

The plus sign should already be URI-encoded (as %2B).  That's how you put an email address with a plus sign in a URL in the first place.

My_Nguyen
Level 2

Re: Making Form Fields Read Only

The email address token was used to insert the email address into the link inside an email. Is there anything that can be done to make it automatically turn that plus sign into %2B?

SanfordWhiteman
Level 10 - Community Moderator

Re: Making Form Fields Read Only

You have to use a Velocity token to URI-encode any content that isn't already URI-encoded. (Far too many many people ignore this, see another example in my comment here: )

My_Nguyen
Level 2

Re: Making Form Fields Read Only

Is this correct for the email scripting token?

$esc.url(${lead.Email})

It seems like Marketo Sky keeps rewriting the code.

SanfordWhiteman
Level 10 - Community Moderator

Re: Making Form Fields Read Only

Don't know what Sky would have to do with it?

You'd be adding within the Script Editor.

Make sure you check off the lead.Email field in the tree on the right-hand side of the editor.

And you need to output the entire link from the Velocity code (this is always the case) not just the URL:

<a href="https://www.example.com/?email=${esc.url($lead.Email)}">link text</a>