This extension bundles an event and corresponding form controls for easier & integrated control of your frontend forms in one place.
If you ever had to submit data from Frontend to more than 1 section and those sections are linked together through a SBL/SBL+ field, I think you already felt the pain of customizing your events.
Using this approach, those relations are handled on-the-fly and no more customizations are required.
- One event to rule them all. It takes the form data and dispatches the processing for all sections where it should be. It also takes care of linking the entries to each other.
- Up to date Form controls. More complex fields have arisen lately. @nickdunn's Form Controls have fallen behind. The
Section Form Controls
offer updated and flexible utilities to help with the new fields and challenges. - Built in multiple entries support. Multiple entries are now supported by default without needing to apply another filter. Using
Section Form Controls
refactoring the XSLT code support multiple entries it's a breeze.
Installation as usual.
- attach
Sections
event to your Pages - copy
/extensions/sections_event/utilities/sform-controls
folder to/workspace/utilities/sform-controls
- import
/utilities/sform-controls/sform-controls.xsl
in yourpage.xsl
- add the
sform
namespace to yourpage.xsl
(eg:xmlns:sform="http://xanderadvertising.com/xslt"
) - start building forms!
The utilities are documented and the code is (I hope) self-explanatory.
However, here we go. All utilities use these parameters:
handle
- an xPath like string that identifies the field data. Usually it's just the handle of the field.value
- the value to be sent with the form. Varies from controller to controller.attributes
- an XML representing the attributes that will be attached to the controller. For each controller some attributes are calculated automatically.event
- the Sections eventsection
- handle of the section to where this controller sends it's dataposition
- index of this entry in amultiple entries
situation
Here are some examples:
If you don't specify the section, the __fields
keyword is used. This is handy if you don't necessarily want to set data for an Entry.
<xsl:call-template name="sform:input">
<xsl:with-param name="handle" select="'title'"/>
<xsl:with-param name="attributes">
<placeholder>Insert title here</placeholder>
</xsl:with-param>
</xsl:call-template>
result:
<input type="text" placeholder="Insert title here" id="sections-__fields-title" name="sections[__fields][title]">
<xsl:call-template name="sform:input">
<xsl:with-param name="handle" select="'title'"/>
<xsl:with-param name="value" select="'Encyclopedia'"/>
<xsl:with-param name="section" select="'books'"/>
</xsl:call-template>
result:
<input type="text" value="Encyclopedia" id="sections-books-title" name="sections[books][title]">
<!-- Book #0 -->
<xsl:call-template name="sform:input">
<xsl:with-param name="handle" select="'title'"/>
<xsl:with-param name="value" select="'Encyclopedia'"/>
<xsl:with-param name="section" select="'books'"/>
<xsl:with-param name="position" select="0"/>
</xsl:call-template>
<!-- Book #1 -->
<xsl:call-template name="sform:input">
<xsl:with-param name="handle" select="'title'"/>
<xsl:with-param name="value" select="'XSLT Cookbook'"/>
<xsl:with-param name="section" select="'books'"/>
<xsl:with-param name="position" select="1"/>
</xsl:call-template>
result:
<input type="text" value="Encyclopedia" id="sections-books-0-title" name="sections[books][0][title]">
<input type="text" value="XSLT Cookbook" id="sections-books-1-title" name="sections[books][1][title]">
<!-- Author #0 -->
<xsl:call-template name="sform:input">
<xsl:with-param name="handle" select="'name'"/>
<xsl:with-param name="value" select="'John'"/>
<xsl:with-param name="section" select="'authors'"/>
<xsl:with-param name="position" select="0"/>
</xsl:call-template>
<!-- Author #1 -->
<xsl:call-template name="sform:input">
<xsl:with-param name="handle" select="'name'"/>
<xsl:with-param name="value" select="'Mary'"/>
<xsl:with-param name="section" select="'authors'"/>
<xsl:with-param name="position" select="1"/>
</xsl:call-template>
<!-- Author #2 -->
<xsl:call-template name="sform:input">
<xsl:with-param name="handle" select="'name'"/>
<xsl:with-param name="value" select="'Andrew'"/>
<xsl:with-param name="section" select="'authors'"/>
<xsl:with-param name="position" select="2"/>
</xsl:call-template>
<!-- Book #0 -->
<xsl:call-template name="sform:input">
<xsl:with-param name="handle" select="'title'"/>
<xsl:with-param name="value" select="'Encyclopedia'"/>
<xsl:with-param name="section" select="'books'"/>
<xsl:with-param name="position" select="0"/>
</xsl:call-template>
<xsl:call-template name="sform:input">
<xsl:with-param name="handle" select="'authors'"/>
<xsl:with-param name="value" select="'authors[0], authors[2]'"/>
<xsl:with-param name="section" select="'books'"/>
<xsl:with-param name="position" select="0"/>
<xsl:with-param name="attributes">
<type>hidden</type>
</xsl:with-param>
</xsl:call-template>
<!-- Book #1 -->
<xsl:call-template name="sform:input">
<xsl:with-param name="handle" select="'title'"/>
<xsl:with-param name="value" select="'XSLT Cookbook'"/>
<xsl:with-param name="section" select="'books'"/>
<xsl:with-param name="position" select="1"/>
</xsl:call-template>
<xsl:call-template name="sform:input">
<xsl:with-param name="handle" select="'authors'"/>
<xsl:with-param name="value" select="'authors[1]'"/>
<xsl:with-param name="section" select="'books'"/>
<xsl:with-param name="position" select="0"/>
<xsl:with-param name="attributes">
<type>hidden</type>
</xsl:with-param>
</xsl:call-template>
result:
<input type="text" value="John" id="sections-authors-0-name" name="sections[authors][0][name]">
<input type="text" value="Mary" id="sections-authors-1-name" name="sections[authors][1][name]">
<input type="text" value="Andrew" id="sections-authors-2-name" name="sections[authors][2][name]">
<input type="text" value="Encyclopedia" id="sections-books-0-title" name="sections[books][0][title]">
<input type="hidden" value="authors[0], authors[2]" id="sections-books-0-authors" name="sections[books][0][authors]">
<input type="text" value="XSLT Cookbook" id="sections-books-1-title" name="sections[books][1][title]">
<input type="hidden" value="authors[1]" id="sections-books-0-authors" name="sections[books][0][authors]">
<xsl:call-template name="sform:input">
<xsl:with-param name="handle" select="'birthday/start/ '"/>
<xsl:with-param name="attributes">
<type>date</type>
<placeholder>Birthday</placeholder>
</xsl:with-param>
</xsl:call-template>
result:
<input type="date" placeholder="Birthday" id="sections-__fields-birthday-start" name="sections[__fields][birthday][start][]">