Skip to content

Commit 82956d8

Browse files
authored
Forms: persist form title attribute (#45908)
* changelog * persist formTitle attribute * update tests
1 parent 9aabf45 commit 82956d8

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Significance: minor
2+
Type: added
3+
4+
Forms: add formTitle on default attributes so it persists throughout parsing and processing

projects/packages/forms/src/contact-form/class-contact-form.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ public function __construct( $attributes, $content = null, $set_id = true ) {
209209
'notificationRecipients' => array(), // Array of user IDs who should receive form response notifications.
210210
'disableGoBack' => $attributes['disableGoBack'] ?? false,
211211
'disableSummary' => $attributes['disableSummary'] ?? false,
212+
'formTitle' => $attributes['formTitle'] ?? '',
212213
);
213214

214215
$attributes = shortcode_atts( $this->defaults, $attributes, 'contact-form' );

projects/packages/forms/tests/php/contact-form/Contact_Form_Test.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2831,6 +2831,7 @@ public function test_get_instance_from_jwt_returns_with_all_attribute_data() {
28312831
'mailpoet' => '',
28322832
'emailNotifications' => 'yes',
28332833
'disableGoBack' => false,
2834+
'formTitle' => 'Test Form',
28342835
);
28352836
// Add a widget ID to the attributes for testing.
28362837
$expected_attributes = $attributes;
@@ -2844,7 +2845,7 @@ public function test_get_instance_from_jwt_returns_with_all_attribute_data() {
28442845
$expected_attributes['disableSummary'] = '';
28452846
$expected_attributes['confirmationType'] = '';
28462847
$expected_attributes['hostingerReach'] = '';
2847-
2848+
$expected_attributes['formTitle'] = 'Test Form';
28482849
$form = new Contact_Form(
28492850
$attributes,
28502851
"[contact-field label='Name' type='name' required='1'/]"

0 commit comments

Comments
 (0)