First up, we are going to add a new select listbox component to our form which will be used to indicate whether a particular submission has been previously flagged as declined.
To add a component to our form we need to be logged in to our site, navigate to our Speaker Registration form, and click on the Webform tab. By default, we should now see the Form components page.
New component name
and give the new component the name of Status
. Select options
and click on Add. Accepted
as the Default value. Accepted|Accepted
on the first line and Declined|Declined
on the next line. Root
under Parent Fieldset. -50
(minus fifty) under Weight.We have now created a new listbox component to store the Status of each submission. The status can be either Accepted
or Declined
, with Accepted
being the default value. This means that all the existing submissions that were completed prior to this component being added will appear as being Accepted
when we edit them.
The new component will appear at the very top of the form as it has the lowest weight. Since we marked the component as Private, it will only be visible to those users who have at least Access all webform results permissions, and it will not be visible to any speakers who visit the Speaker Registration form.
This is the component whose value will decide whether or not our custom action will be shown when submissions are being viewed or edited. While the value of our Status component is Accepted
or blank (as in the case of submissions already stored at the time that we created the new component), our administrators will be presented with the option to decline a submission.
Adding this component has been the first step towards achieving the goals laid out for our action. Our next preparatory step is to obtain the component identifiers for the fields we will need to use in our action handler.
The data submitted via our form is stored as an array of values within a $submission
object. To access the values submitted for particular components we need to know what the component identifier values are (the component identifier is a numeric value assigned to each component that we create on our form) for the respective components. Armed with the identifier we can access the $submission->data
array to retrieve relevant submitted data.
The components whose values are pertinent to our action handler are those for speaker name, speaker surname, speaker e-mail address, presentation title, and most importantly, the status component we just added.
Perhaps the easiest method of discovering component identifiers is by hovering our mouse pointer over the Edit link that appears under the heading of OPERATIONS on our component overview page.
A portion of the URL (that is, hyperlink) contains the text webform/components/
followed by a number. That number is the component identifier for the component on that row. Let us make a note of the CIDs (component identifiers) for the five components we need: First name, Last name, Email address, Presentation title, and Status. Later in the exercise we will be able to use this information to interact meaningfully with the Webform $submission
object to extract submitted data.