public function validate($attribute, $value, $parameters, $validator) { $isValid = true; // We only validate, if honeypot-protection is basically enabled in the config. if (config('htmlbuilder.formBuilder.honeypot.enabled')) { $honeypotFieldName = FormBuilderTools::getHoneypotFieldName(); $fullRequest = Request::all(); if (isset($fullRequest[$honeypotFieldName])) { if (strlen($fullRequest[$honeypotFieldName]) > 0) { $isValid = false; } } else { $isValid = false; } } return $isValid; }
/** * Append the honeypot-field, if honeypot-protection is enabled in the config. */ protected function task_1100_handleHoneypotProtection() { if (config('htmlbuilder.formBuilder.honeypot.enabled')) { // We retrieve the honeypot-rules. $honeypotRules = app()['formbuilder']->getRulesForField('_honeypot'); // If there are any, ... if (strlen($honeypotRules) > 0) { // ...we add the honeypot-field wrapped in a hidden fieldset. $this->output .= app()->make(InputText::class, [FormBuilderTools::getHoneypotFieldName()])->label(trans('Nicat-HtmlBuilder::htmlbuilder.honeypotFieldLabel'))->value("")->errors(app()['formbuilder']->getErrorsForField('_honeypot'))->addWrapperModifier('hidden', [true])->generate(); } } }