-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: corrected form data notification (#91)
* fix: corrected form data notification email * fix: corrected variable names * fix: corrected values and helper * chore: docs * fix: reset
- Loading branch information
1 parent
c6976e1
commit 6dd8cb7
Showing
3 changed files
with
84 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
namespace ModularityFormBuilder\Helper; | ||
|
||
class NestedFields | ||
{ | ||
/** | ||
* Creates a nested array from field data. | ||
* | ||
* This function takes an array of field data and converts it into a nested array format. | ||
* Each element in the input array is transformed into an associative array with 'key' and 'value' keys. | ||
* The 'key' is obtained by removing the prefix 'id-' and sanitizing the original key. | ||
* | ||
* @param array $fieldData The input array of field data. | ||
* @return array The nested array created from the field data. | ||
*/ | ||
public static function createNestedArrayFromFieldData($fieldData) | ||
{ | ||
$nestedDataArray = []; | ||
if (is_array($fieldData)) { | ||
foreach ($fieldData as $key => $value) { | ||
$pattern = '/^id-\d+-/'; | ||
$key = preg_replace($pattern, "", sanitize_title($key), 1); | ||
$nestedDataArray[] = [ | ||
'key' => $key, | ||
'value' => $value | ||
]; | ||
} | ||
} | ||
|
||
return $nestedDataArray; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters