Creating a Template TV of Forms to select from
Created by Charles Sanders on Oct 13, 2013.
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
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.
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]]` ]]
Suggest an edit to this page on GitHub (Requires GitHub account. Opens a new window/tab) or become an editor of the MODX Documentation.