Problem/Motivation

It would be great if the default "Send message" button text could be overridden.

Proposed resolution

Add a "Submit button text" field on each contact form's "edit" page, make the magic happen.

Remaining tasks

Review and commit (please).

User interface changes

The addition of a new "Submit button text" field.

API changes

None.

Data model changes

None.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ultimike created an issue. See original summary.

Status: Needs review » Needs work

The last submitted patch, submit_button_text.patch, failed testing.

andypost’s picture

+++ b/contact_storage.module
@@ -24,6 +24,12 @@ function contact_storage_form_contact_form_form_alter(&$form, FormStateInterface
+    '#default_value' => $contact_form->getThirdPartySetting('contact_storage', 'submit_text', FALSE),

here should be default value somehow

larowlan’s picture

Issue tags: +Needs tests
+++ b/contact_storage.module
@@ -32,6 +38,7 @@ function contact_storage_form_contact_form_form_alter(&$form, FormStateInterface
+  $contact_form->setThirdPartySetting('contact_storage', 'submit_text', $form_state->getValue('contact_storage_submit_text'));

You need a schema change for this

Also, needs tests.

jamadar’s picture

Assigned: Unassigned » jamadar

I assingned this myself as a part of #TCSHackthon.

jamadar’s picture

jamadar’s picture

Status: Needs work » Needs review

Issue has been fixed please review

nidhi.badani’s picture

Assigned: jamadar » nidhi.badani

Will be reviewing it in next 30mins.

nidhi.badani’s picture

Hey this works, I installed the required module and applied the patch. The submit button text is as specified while creating the form.

Looks good to me.

ultimike’s picture

@jamadar - thanks for taking this on!

I just updated the patch with a couple of small formatting tweaks and the addition a reasonable default value (see comment 3).

It still needs a test. I'm looking into that now.

thanks,
-mike

Status: Needs review » Needs work

The last submitted patch, 10: submit_text-2669794-10.patch, failed testing.

ultimike’s picture

Status: Needs work » Needs review
FileSize
3.32 KB

Ok - here's a patch with a test.

-mike

Status: Needs review » Needs work

The last submitted patch, 12: submit_text-2669794-12.patch, failed testing.

jamadar’s picture

Assigned: nidhi.badani » jamadar

#drupalconasia2016

jamadar’s picture

Issue tags: +#drupalconasia2016
jamadar’s picture

@ultimike Thanks for providing patch.

I have tested this patch at my end and found that there is issue with the test cases in ContactStorageTest.php at line number 77.
Please find attached new updated patch to resolve this issue.

jamadar’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 16: submit_text-2669794-16.patch, failed testing.

jamadar’s picture

Assigned: jamadar » Unassigned
larowlan’s picture

Issue tags: -Needs tests +php-novice, +Novice
  1. +++ b/contact_storage.module
    @@ -39,6 +46,13 @@ function contact_storage_contact_form_form_builder($entity_type, ContactFormInte
    + ¶
    

    whitespace issue here

  2. +++ b/src/Tests/ContactStorageTest.php
    @@ -66,16 +66,15 @@ class ContactStorageTest extends ContactStorageTestBase {
    +    // Make sure the stored message is corresct.
    

    unneeded change

  3. +++ b/src/Tests/ContactStorageTest.php
    @@ -66,16 +66,15 @@ class ContactStorageTest extends ContactStorageTestBase {
    -    $this->drupalPostForm(NULL, array(), t('Save'));
    -    $this->assertUrl('admin/structure/contact/messages');
    -
    +    $this->drupalPostForm('admin/structure/contact/messages', array(), $headers = array(), $form_html_id =NULL, t('Save'));
    +    $this->assertUrl('admin/structure/contact/messages',[]);
    

    Unneeded changes

larowlan’s picture

Assigned: Unassigned » larowlan

Working on this

larowlan’s picture

Status: Needs work » Needs review
FileSize
6.69 KB
5.43 KB
larowlan’s picture

Status: Needs review » Fixed

  • larowlan committed a1f77e2 on 8.x-1.x authored by jamadar
    Issue #2669794 by ultimike, jamadar: Add ability to change the "Send...
  • larowlan committed db6e47d on 8.x-1.x
    Issue #2669794 by ultimike, jamadar, larowlan: Add ability to change the...
larowlan’s picture

larowlan’s picture

Title: Add ability to change the "Send message" button text » Add ability to change the "Send message" button text and hide preview button

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.