Oh gosh. I hope this makes sense! There are a number of methods in the core MapField class that are extracted only to break apart a long chain of block-building.
Not sure how much help this will be, but I thought I’d record some thoughts on multi-input fields.
Regardless of your approach, be sure that you construct all input elements’ name
values appropriately:
<input type="text" name="fieldHandle[yourSubFieldName]" />
<input type="text" name="fieldHandle[yourOtherSubFieldName]" />
…where fieldHandle
is retrieved by using $this->name()
.
The bracket notation is key. On this line, you’ll see the plugin getting the result
of a submission, which is all the values passed within the field’s key, so in the case of the above, you’d receive an array:
[
'yourSubFieldName' => 'text content of the first input',
'yourOtherSubFieldName' => 'text content of the second input'
]
Don’t add data to the base key— it may get clobbered. For example you can’t have these three inputs:
<input type="text" name="fieldHandle" /> (This one will not reliably be passed to your field)
<input type="text" name="fieldHandle[yourSubFieldName]" />
<input type="text" name="fieldHandle[yourOtherSubFieldName]" />
Instead, namespace all your inputs. The first line would then become <input type="text" name="fieldHandle[firstSubField]" />
.
With respect to the original question— as long as your inputs are properly name-spaced, the data will be available through parent::result()
. It doesn’t matter where exactly they are in the tree you construct in the field’s content
method. As I understand it, the input
method is only a convention, but content
is what is actually responsible for returning the field’s markup.
August