Jump to main content Jump to doc navigation

Create Form List in TV

Other versions: 2.x (current) — Found a problem? Please edit this page or report an issue.

TV from mxFormBuilder's Form List

You could create a quick TV to allow content creators to select from any of the published forms created in mxFormBuilder with the packaged mxfbTVFormList snippet.

Creating the TV

In your Manager select elements tab from the left panel and then right mouse click Elements -or- click on the TV icon in the menu bar. When the new template varible window displays you can provide the information you desire in the General Information tab, in our case we used the following:

  • Name - mxform
  • Caption - Select Form
  • Description - (enter more information about the specific use case in your templates)

Now select the Input Options tab and select your input type you want the users to interact with; I always select Listbox (Single-Select). Then we need to tell the TV that we want to use the renderings from our snippet to populate the content for the select list, so in our Input Options Values content area place the following:

@EVAL return '-- Select --||' . $modx->runSnippet('mxfbTvFormList');

This should look something like below

By default only active forms and forms that are have blank (non-set) context and/or current context are listed. Specify the &context or &active to change default filtering as needed. Ex: $modx->runSnippet('mxfbTvFormList', array('context'=>'web') )

Then you can set any additional properties you need for your specific use. The only other thing that I normally set is the templates that we want to have access to the TV. Click on the Template Access tab and place a check next to each template that you want to have this TV option visible. Now save your new TV.

TV Selection

After you have saved your new TV load a resource that uses any of the templates that you allowed access to the TV. Default rendering of the TV in the new resource will now be displayed in the Template Variables tab of the resource.

Example TV was placed in a category called mxFormBuilder; this will depend on your specific category assigned during creating the TV and any Form Customization.

Displaying the Form from assigned in TV

Now that we've got our TV and a Resource set with a selected form lets actually display the form. In the area that you want to display the form we need to call the mxfb snippet and pass the &formid parameter value of the TV.

[[!mxfb? &formid=`[[*mxform]]` ]]

Note that mxform is the name of the TV we created in our example. Update this to match the name you specified as your TV's name.

mxFormBuilder will only process if it finds a valid parameter for formid