@@ -133,8 +133,11 @@ protected function setDigitalFormFromFormState(array &$form, FormStateInterface
133
133
/*
134
134
* This form is creating a new Digital Form.
135
135
*
136
- * Create the new Digital Form with the fields from this form.
136
+ * We need to create a new Digital Form by doing two things:
137
+ * 1. Create the new Digital Form with the fields from this form.
138
+ * 2. Add default "Your personal information" step.
137
139
*/
140
+ // 1. Create the new Digital Form with the fields from this form.
138
141
$ node = $ this ->entityTypeManager ->getStorage ('node ' )->create ([
139
142
'type ' => 'digital_form ' ,
140
143
'title ' => $ title ,
@@ -143,6 +146,29 @@ protected function setDigitalFormFromFormState(array &$form, FormStateInterface
143
146
'field_respondent_burden ' => $ respondentBurden ,
144
147
'field_expiration_date ' => $ expirationDate ,
145
148
]);
149
+
150
+ // 2. Add "Your personal information" step (paragraph).
151
+ // This step contains two sub-steps:
152
+ // --> Name and date of birth
153
+ $ nameAndDobParagraph = $ this ->entityTypeManager ->getStorage ('paragraph ' )->create ([
154
+ 'type ' => 'digital_form_name_and_date_of_bi ' ,
155
+ 'field_title ' => 'Name and date of birth ' ,
156
+ 'field_include_date_of_birth ' => TRUE ,
157
+ ]);
158
+ // --> Identification information
159
+ $ identificationInfo = $ this ->entityTypeManager ->getStorage ('paragraph ' )->create ([
160
+ 'type ' => 'digital_form_identification_info ' ,
161
+ 'field_title ' => 'Identifying information ' ,
162
+ 'field_include_veteran_s_service ' => TRUE ,
163
+ ]);
164
+ // Your personal information wraps both.
165
+ $ yourPersonalInformation = $ this ->entityTypeManager ->getStorage ('paragraph ' )->create ([
166
+ 'type ' => 'digital_form_your_personal_info ' ,
167
+ 'field_name_and_date_of_birth ' => $ nameAndDobParagraph ,
168
+ 'field_identification_information ' => $ identificationInfo ,
169
+ ]);
170
+ $ node ->get ('field_chapters ' )->appendItem ($ yourPersonalInformation );
171
+
146
172
$ this ->digitalForm = $ this ->digitalFormsService ->wrapDigitalForm ($ node );
147
173
}
148
174
else {
0 commit comments