@@ -15,19 +15,29 @@ class FormHelper {
1515 * Hide section page paragraph block reference options.
1616 */
1717 public function alterForm (array &$ form , FormStateInterface $ formState , string $ formId ) {
18- if ($ formId == 'node_os2loop_section_page_edit_form ' || $ formId == 'node_os2loop_section_page_form ' ) {
18+ $ alterWidgetSettings = static function (array &$ element ) {
19+ if (isset ($ element ['os2loop_section_page_block ' ]['widget ' ][0 ]['settings ' ])) {
20+ $ element ['os2loop_section_page_block ' ]['widget ' ][0 ]['settings ' ]['views_label_checkbox ' ]['#access ' ] = FALSE ;
21+ $ element ['os2loop_section_page_block ' ]['widget ' ][0 ]['settings ' ]['views_label_fieldset ' ]['#access ' ] = FALSE ;
22+ $ element ['os2loop_section_page_block ' ]['widget ' ][0 ]['settings ' ]['views_label_field ' ]['#access ' ] = FALSE ;
23+ $ element ['os2loop_section_page_block ' ]['widget ' ][0 ]['settings ' ]['label_display ' ]['#access ' ] = FALSE ;
24+ // Don't show the view label.
25+ $ element ['os2loop_section_page_block ' ]['widget ' ][0 ]['settings ' ]['label_display ' ]['#default_value ' ] = FALSE ;
26+ $ element ['os2loop_section_page_block ' ]['widget ' ][0 ]['settings ' ]['label ' ]['#access ' ] = FALSE ;
27+ }
28+ };
29+
30+ if (preg_match ('/node_os2loop_section_page(_edit)?_form/ ' , $ formId ) && isset ($ form ['os2loop_section_page_paragraph ' ]['widget ' ])) {
1931 foreach ($ form ['os2loop_section_page_paragraph ' ]['widget ' ] as $ widget_key => $ widget ) {
2032 if (is_array ($ widget ) && is_numeric ($ widget_key ) && isset ($ widget ['subform ' ])) {
21- $ form ['os2loop_section_page_paragraph ' ]['widget ' ][$ widget_key ]['subform ' ]['os2loop_section_page_block ' ]['widget ' ][0 ]['settings ' ]['views_label_checkbox ' ]['#access ' ] = FALSE ;
22- $ form ['os2loop_section_page_paragraph ' ]['widget ' ][$ widget_key ]['subform ' ]['os2loop_section_page_block ' ]['widget ' ][0 ]['settings ' ]['views_label_fieldset ' ]['#access ' ] = FALSE ;
23- $ form ['os2loop_section_page_paragraph ' ]['widget ' ][$ widget_key ]['subform ' ]['os2loop_section_page_block ' ]['widget ' ][0 ]['settings ' ]['views_label_field ' ]['#access ' ] = FALSE ;
24- $ form ['os2loop_section_page_paragraph ' ]['widget ' ][$ widget_key ]['subform ' ]['os2loop_section_page_block ' ]['widget ' ][0 ]['settings ' ]['label_display ' ]['#access ' ] = FALSE ;
25- // Don't show the view label.
26- $ form ['os2loop_section_page_paragraph ' ]['widget ' ][$ widget_key ]['subform ' ]['os2loop_section_page_block ' ]['widget ' ][0 ]['settings ' ]['label_display ' ]['#default_value ' ] = FALSE ;
27- $ form ['os2loop_section_page_paragraph ' ]['widget ' ][$ widget_key ]['subform ' ]['os2loop_section_page_block ' ]['widget ' ][0 ]['settings ' ]['label ' ]['#access ' ] = FALSE ;
33+ $ alterWidgetSettings ($ form ['os2loop_section_page_paragraph ' ]['widget ' ][$ widget_key ]['subform ' ]);
2834 }
2935 }
3036 }
37+
38+ if (preg_match ('/paragraph_os2loop_section_page_.+_form/ ' , $ formId )) {
39+ $ alterWidgetSettings ($ form );
40+ }
3141 }
3242
3343}
0 commit comments