Form Descriptor Object | Community
Skip to main content
May 11, 2017
Solved

Form Descriptor Object

  • May 11, 2017
  • 1 reply
  • 2953 views

OK, I'm missing something. It's probably obvious, but I'm not seeing it.

MktoForms2 has a method called newForm() which looks potentially useful. It takes a Form Descriptor Object as an argument. But aside from the quick "as created by the Marketo Forms V2 editor" mentioned at the end of it, I don't see a definition for it or even where to get one so I can look at it. I went through the form editor, closest reference I could find was the form embed code, which isn't it. None of the other methods listed on the page return one. Plenty of ways to get a Form object, but that's not it (I tried and it errors out).

So, what did I miss? Where do I get my digital claws on a Form Descriptor Object?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by SanfordWhiteman

I'm not talking about MktoForms2.getForm().  I'm talking about the /getForm JSONP endpoint. In the inner JSON is a form descriptor.

I absolutely would not use live REST API calls to pull form descriptors for rendering. It's designed for editing.

1 reply

SanfordWhiteman
Level 10
May 11, 2017

getForm returns form descriptors. The REST Asset API can manage descriptors. A descriptor is simply the serialized representation of a form's fields/rules/layout/etc.

May 12, 2017

I thought I replied to this yesterday. Well that's consistent with the rest of the day I was having, I guess. Anyway:

I tried MktoForms2.getForm() before posting. Didn't work. It got a Form Object, as described in the docs, but apparently that's not the same as a Form Descriptor object, because when I fed the received Form Object into MktoForms2.newForm() it died with a TypeError inside the minimized Marketo js file. But even had it worked, .getForm() requires the Form object to have already been created before it gets it. I was looking for a way to create the Marketo Form Object before rendering the form itself, hopefully completely stopping it from rendering until and unless necessary.

But thanks for the pointer to the REST API. I've wandered around in there before, looking for something else, but I remember there are several JSON structures in there, so perhaps I can hack together something based on one of those that will work. If not I'll probably have to fall back on a .loadForm() call; it'll work for me, after a fashion, but if I could get newForm() to work the way the docs let me think it works, it'll be cleaner.

(Context: I'm trying to pull multiple forms, then show a particular one after a user's action. It's cleaner if I have them all in hand, just waiting to be rendered. The best alternative I've found involves rendering *all* of them as hidden, then moving and/or revealing them after user action dictates which form should appear. It works, and yields a faster apparent response time than waiting to load the form until after the user acts, but it seems like it would be still faster and feels cleaner to me if I only render the one I need to render. I won't know if there's an actual speed gain until I'm able to test both approaches, hence this. IOW, I have two ways that work in front of me and I'm looking for a better way. Yes, as a matter of fact I *am* fussy, why do you ask?)

SanfordWhiteman
SanfordWhitemanAccepted solution
Level 10
May 12, 2017

I'm not talking about MktoForms2.getForm().  I'm talking about the /getForm JSONP endpoint. In the inner JSON is a form descriptor.

I absolutely would not use live REST API calls to pull form descriptors for rendering. It's designed for editing.