Commit eae5dcc8 authored by catch's avatar catch

Issue #2960353 by alena_stanul, DevJoJodae, munish.kumar, MrMason, ckaotik,...

Issue #2960353 by alena_stanul, DevJoJodae, munish.kumar, MrMason, ckaotik, opi, pankaj.singh, Manuel Ferreira, mherman-pro: Make the Preview button on the Contact Forms to obey the "Manage form display" field settings
parent 73d179af
......@@ -174,6 +174,7 @@ public function actions(array $form, FormStateInterface $form_state) {
'#type' => 'submit',
'#value' => $this->t('Preview'),
'#submit' => ['::submitForm', '::preview'],
'#access' => !empty($form_state->getStorage()['form_display']->getComponent('preview')),
];
return $elements;
}
......
......@@ -408,6 +408,18 @@ public function testSiteWideContact() {
$this->assertEquals(1, substr_count($page_text, t('Message')));
$this->assertSession()->responseContains('class="field field--name-message field--type-string-long field--label-hidden field__item">');
$this->assertSession()->pageTextContains($edit['message[0][value]']);
// Set the preview field to 'hidden' in the view mode and check that the
// field is hidden.
$edit = [
'fields[preview][region]' => 'hidden',
];
$this->drupalPostForm('admin/structure/contact/manage/' . $contact_form . '/form-display', $edit, 'Save');
$this->assertSession()->fieldExists('fields[preview][region]');
// Check that the field preview is not displayed in the form.
$this->drupalGet('contact/' . $contact_form);
$this->assertSession()->responseNotContains('Preview');
}
/**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment