Skip to content

Commit e829caf

Browse files
fix: adjust Form priv verbose names
1 parent 5f8547a commit e829caf

File tree

1 file changed

+11
-1
lines changed
  • pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Core

1 file changed

+11
-1
lines changed

pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Core/Form.inc

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,17 @@ class Form {
165165
private function generate_verbose_name(): string {
166166
# Separate the class name's words with spaces, allow consecutive capital characters like 'DNS'
167167
$form_name = $this->get_class_shortname();
168-
return preg_replace('/(?<=[a-z])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])/', ': ', $form_name);
168+
$verbose_name = preg_replace('/(?<=[a-z])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])/', ' ', $form_name);
169+
170+
# Add a colon after the first word if the class name is more than one word
171+
if (str_contains($verbose_name, ' ')) {
172+
$verbose_name = explode(' ', $verbose_name);
173+
$verbose_name[0] .= ': ';
174+
$verbose_name = implode(' ', $verbose_name);
175+
}
176+
177+
# Return the verbose name with the 'Form' suffix removed
178+
return str_replace(' Form', '', $verbose_name);
169179
}
170180

171181
/**

0 commit comments

Comments
 (0)