all(); $lastSection = $form->count() ? $formNodes[$form->count() - 1] : null; if ($lastSection && is_null($form->getNodeByName($honeypotFieldName))) { $field = Honeypot::make($honeypotFieldName) ->label($this->generateLabelFromFieldName($honeypotFieldName)) ->scope('honeypot') ->showInAdmin(false) ->showInReceipt(false) ->rules(new HoneyPotRule()); $lastSection->append($field); } } /** * @since 3.17.0 */ private function generateLabelFromFieldName(string $honeypotFieldName): string { return ucwords(trim(implode(" ", preg_split("/(?=[A-Z])/", $honeypotFieldName)))); } }