Skip to content

Commit

Permalink
Merged PR 45662: Fix data field input types for widget
Browse files Browse the repository at this point in the history
## What's being changed

This PR repairs the HTML of the signup form widget by setting the expected input types according to each Dotdigital data field type.

| Dotdigital data field type | HTML input type |
| -- | -- |
| Text | text |
| Date | date |
| Numeric | number |
| Yes/No | radio |

We also fixed a deprecated notice for `uasort` return type in PHP 8.1+, and cleaned up the method that outputs the field input HTML.

## Why it's being changed

Previously the HTML was invalid and had e.g. `<input type='FIRSTNAME'>`.

## How to review / test this change

- Check out the related branch on the SDK
- Add a repositories path in composer.json to your local SDK
- Run `composer update` in the plugin root folder
- Test sorting for data fields
- Test sorting for address books
- Ensure you have selected a data field corresponding to each of the types from the table above
- Add these to the widget
- Check the HTML to confirm the input types match the appropriate data field type
- Test form submission and mapping of data field values into Dotdigital

## Notes

Since the previous version of this plugin, we have refactored our PHP SDK. As a result the code now respects the revised namespace (`Dotdigital\V2`) for the v2 API.

Related work items: #212887
  • Loading branch information
sta1r committed Jun 19, 2023
1 parent 36a573e commit 0c3373a
Show file tree
Hide file tree
Showing 245 changed files with 5,523 additions and 2,573 deletions.
22 changes: 12 additions & 10 deletions DotdigitalConnect.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

require_once __DIR__ . '/vendor/autoload.php';

use Dotdigital\Client;
use Dotdigital\Models\Contact;
use Dotdigital\Models\ContactList;
use Dotdigital\V2\Client;
use Dotdigital\V2\Models\Contact;
use Dotdigital\V2\Models\ContactList;

class DotdigitalConnect {

Expand All @@ -28,7 +28,7 @@ public function __construct( array $credentials ) {
}

/**
* @return \Dotdigital\Models\AccountInfo|bool
* @return \Dotdigital\V2\Models\AccountInfo|bool
* @throws \Http\Client\Exception
*/
public function getAccountInfo() {
Expand All @@ -40,19 +40,21 @@ public function getAccountInfo() {
}

/**
* @return \Dotdigital\Models\AddressBookList
* @return \Dotdigital\V2\Models\AddressBook[]
* @throws \Http\Client\Exception
*/
public function listAddressBooks() {
return $this->client->addressBooks->show();
$apiLists = $this->client->addressBooks->show();
return $apiLists->getList();
}

/**
* @return \Dotdigital\Models\DataField[]|\Dotdigital\Models\DataFieldList
* @return \Dotdigital\V2\Models\DataField[]
* @throws \Http\Client\Exception
*/
public function listDataFields() {
return $this->client->dataFields->show();
$apiDataFields = $this->client->dataFields->show();
return $apiDataFields->getList();
}

/**
Expand All @@ -65,7 +67,7 @@ public function listDataFields() {
*/
public function addContactToAddressBook( $email, $addressBookId, $datafields = array() ) {
try {
$apiContact = new Dotdigital\Models\Contact(
$apiContact = new Dotdigital\V2\Models\Contact(
array(
'id' => -1,
'email' => $email,
Expand Down Expand Up @@ -101,7 +103,7 @@ public function addContactToAddressBook( $email, $addressBookId, $datafields = a
* @throws \Http\Client\Exception
*/
public function resubscribeContactToAddressBook( $email, $addressBookId, $datafields = array() ) {
$apiContact = new Dotdigital\Models\Contact(
$apiContact = new Dotdigital\V2\Models\Contact(
array(
'id' => -1,
'email' => $email,
Expand Down
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
],
"require": {
"php": "^7.4 || ^8.0",
"dotdigital/dotdigital-php": "1.0.0",
"dotdigital/dotdigital-php": "2.0.0-RC1",
"php-http/guzzle7-adapter": "^1.0",
"symfony/deprecation-contracts": "^2.2",
"symfony/options-resolver": "~5.0"
Expand All @@ -21,7 +21,8 @@
},
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
"dealerdirect/phpcodesniffer-composer-installer": true,
"php-http/discovery": true
}
}
}
Loading

0 comments on commit 0c3373a

Please sign in to comment.