Super easy. There is the XML file itself, which defines the form. If your data lends itself to being displayed in a table, the plugin will take care of that for you, using the field labels as the column headings on the table.
If not, you can create an output template PHP file, just name it the same as the XML file and place it in the same directory. The subform value will be available to your script as the variable $value. In my example, I created a PHP class to handle all of the stuff I was doing, but that isn't necessary. You can bust up the $value using json_decode and handle the data any way you see fit.
If your subform needs custom fields, the twittercard example shows how to do that, and if you need to translate the twittercard example shows that too.
Don't let the output template intimidate you. Start with "<?php echo $value;" and go from there. If you can write PHP, you will do fine.
Hi Michael, thanks for the reply.
I've got over my initial confusion, I had a different expectation for how to configure the whole thing i.e. just adding in fields by selection. But I'm pretty sure your plugin will help me get to where I need to be.
What I want to achieve is a selectbox for a user to choose a subform for article info.
That might be embedded video info, author info, article references, credits etc.
What I don't want, is to have to show all that on a page when some will not be used, I'd just like the relevant fields be available when they're needed. (these things will only be one or the other i.e video info or pdf info, not both)
It can do that right?
And can I put subforms in a subform?
I'd like to join some fields together i.e for url it should always have "url text" and title fields so 1 url field + 2 text fields (displayed as one item)
Can it do that? I'm assuming I can load as many subforms as I want into one form?
Which of the fields in your twittercard is a custom field? They all just look like normal fields.
You'll want to spend some time reviewing what can be done with JForm XML - because my subform plugin can do most of it.
I've found myself making super complex subforms, only to realize that I can have as many subform fields as I want. Try to conceptualize your data in discrete units of related data elements. So, for your video info, make a subform with a checkbox and all of the related video info fields. When the user checks the "this is a video" checkbox, the rest appear using the showon="video:1" JForm XML attribute. Same for PDF and others. This way you aren't making forms so complex that they can't work. My plugin will display valid JForm XML - but it's possible to paint yourself into a logical corner by making a form too complex to actually work.
subform within subform - yes and no. Yes it can be done, but nested subforms cannot have multiple values (yet, there's a PR which implements that feature in either Joomla 3.9 or 3.10)
Here's an example (from this site) of me breaking up the data into many subforms (every green + is a repeating subform field). First I was writing a super complex subform, until I painted myself into a corner. So I started over and painted myself into another corner. Fast forward a half dozen tries to come up with a data model that worked - I realized that I didn't need to cram all of the values I wanted into the subform, I just needed to make several subforms to cover the types of data I was storing.
In my output templates, if the data doesn't exist - the output template exits early. So instead of building logic to handle different types differently - you could create subforms to hold the data you want, and if it's not there the subform field displays nothing.
That approach greatly simplified what I was initially making way too complex.