Skip to content

Commit

Permalink
adding custom wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
iruzevic committed Jan 31, 2024
1 parent 7c1f097 commit 9b58eeb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.

This projects adheres to [Semantic Versioning](https://semver.org/) and [Keep a CHANGELOG](https://keepachangelog.com/).

## [1.1.3]

### Added
- `getPartialFormFieldNames` function can now accept a custom wrapper for output.

## [1.1.2]

### Added
Expand All @@ -23,6 +28,7 @@ This projects adheres to [Semantic Versioning](https://semver.org/) and [Keep a

- Initial production release.

[1.1.3]: https://github.com/infinum/eightshift-forms-utils/compare/1.1.2...1.1.3
[1.1.2]: https://github.com/infinum/eightshift-forms-utils/compare/1.1.1...1.1.2
[1.1.1]: https://github.com/infinum/eightshift-forms-utils/compare/1.1.0...1.1.1
[1.1.0]: https://github.com/infinum/eightshift-forms-utils/compare/1.0.0...1.1.0
Expand Down
12 changes: 10 additions & 2 deletions src/Helpers/UtilsSettingsOutputHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -281,16 +281,24 @@ public static function getPartialResponseTags(string $formResponseTags): string
* Get all field names from the form.
*
* @param array<int, string> $fieldNames Form field IDs.
* @param string $wrapper Wrapper for the field name.
*
* @return string
*/
public static function getPartialFormFieldNames(array $fieldNames): string
public static function getPartialFormFieldNames(array $fieldNames, string $wrapper = '{}'): string
{
$output = [];

// Populate output.
foreach ($fieldNames as $item) {
$output[] = "<li><code>{" . $item . "}</code></li>";
switch ($wrapper) {
case '$':
$output[] = "<li><code>$" . $item . "</code></li>";
break;
default:
$output[] = "<li><code>{" . $item . "}</code></li>";
break;
}
}

return \implode("\n", $output);
Expand Down

0 comments on commit 9b58eeb

Please sign in to comment.