Closed Karak888 closed 1 week ago
might want to add default things to forms, but what does it mean that it is default, completely hidden from the editor - if so we can add those things after drupal stage -We can add it but text box potentially to let them know it is there
This spike attempted to determine if we can add default paragraphs (steps) upon creating a Digital Form node. In short, the answer to that is yes.
This spike was explored in tandem with another more broad spike that looked at creating a custom wizard-like UX. The code for both spikes is on branch VAGOV-TEAM-89850-91349-form-flow
.
It turns out that this piece of the puzzle should be fairly straightforward. The useful code is here:
$default_paragraph_1 = Paragraph::create([
'type' => 'digital_form_name_and_date_of_bi',
'field_title' => 'Name w/ DOB',
'field_include_date_of_birth' => true,
]);
$default_paragraph_2 = Paragraph::create([
'type' => 'digital_form_name_and_date_of_bi',
'field_title' => 'Name w/out DOB',
'field_include_date_of_birth' => false,
]);
$digital_form = Node::create([
'type' => 'digital_form',
'title' => $form_name,
'field_va_form_number' => $form_number,
'field_omb_number' => $omb_number,
'field_chapters' => [
$default_paragraph_1,
$default_paragraph_2,
],
]);
$digital_form->save();
The risk here feels very low. We will already be creating nodes from scratch, so adding paragraphs by default does not constitute a significant addition.
We can move forward with the understanding that we can create default paragraphs (steps) on our Digital Form nodes.
Overview
It seems that many forms share a set of common steps/chapters. As such, it seems reasonable to think that we'd maybe want to add these steps/chapters by default (possibly opt-out rather than opt-in). We need to determine if this is feasible.
Acceptance Criteria