Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion includes/ZeroBSCRM.Jetpack.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ function zero_bs_crm_capture_jetpack_form( $post_id, $all_field_data, $is_spam,
$contact_data['email'] = jpcrm_jetpack_form_text_value( $field_data->value );
}

if ( 'telephone' === $field_data->get_attribute( 'type' )
// A phone field with the country selector switched on has the type 'phone'.
if ( in_array( $field_data->get_attribute( 'type' ), array( 'telephone', 'phone' ), true )
&& ! isset( $contact_data['hometel'] )
&& ! empty( $field_data->value )
) {
Expand Down
19 changes: 19 additions & 0 deletions tests/php/entities/Jetpack_Form_Capture_Values_Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,25 @@ public function test_an_ordinary_submission_is_stored_as_sent() {
$this->assertSame( '+353 (21) 427-0000', $contact['hometel'] );
}

/**
* @testdox A phone field with the country selector is stored as the contact's phone number.
*/
#[TestDox( 'A phone field with the country selector is stored as the contact\'s phone number.' )]
public function test_a_phone_field_with_the_country_selector_is_stored() {

$this->submit(
array(
$this->form_field( 'g1-email', 'email', 'astrid@example.test' ),
$this->form_field( 'g1-phone', 'phone', '+46 701234567' ),
)
);

$contact = $this->contact_with_email( 'astrid@example.test' );

$this->assertIsArray( $contact, 'No contact was created.' );
$this->assertSame( '+46 701234567', $contact['hometel'] );
}

/**
* @testdox Submitted values are stored as plain text.
*/
Expand Down