protected function applyTagMethods2MatcherData() { $formID = $this->formTemplate['parameters']['id']; $buttonName = $this->tagParameters['name']; $buttonID = $formID . '_' . $buttonName; $this->matchTagAttributes = ['type' => $this->buttonType, 'class' => 'btn', 'id' => $buttonID, 'name' => $buttonName]; $this->matchTagChildren = [['text' => ucfirst($buttonName)]]; parent::applyTagMethods2MatcherData(); $this->addHtmlClass2String($this->matchTagAttributes['class'], 'btn-' . $this->context); }
protected function applyTagMethods2MatcherData() { parent::applyTagMethods2MatcherData(); // Add hidden-input field for _token. if ($this->matchTagAttributes['method'] !== 'GET') { $this->matchTagChildren[] = ['tag' => 'input', 'attributes' => ['type' => 'hidden', 'id' => $this->matchTagAttributes['id'] . '__token', 'class' => 'form-control', 'name' => '_token', 'value' => '']]; } // Add hidden-input field for _formID. $this->matchTagChildren[] = ['tag' => 'input', 'attributes' => ['type' => 'hidden', 'id' => $this->matchTagAttributes['id'] . '__formID', 'class' => 'form-control', 'name' => '_formID', 'value' => $this->matchTagAttributes['id']]]; if ($this->matchTagAttributes['method'] !== 'GET' && $this->matchTagAttributes['method'] !== 'POST') { $this->matchTagChildren[] = ['tag' => 'input', 'attributes' => ['type' => 'hidden', 'id' => $this->matchTagAttributes['id'] . '__method', 'class' => 'form-control', 'name' => '_method', 'value' => $this->matchTagAttributes['method']]]; $this->matchTagAttributes['method'] = 'POST'; } // Add hidden-input honeypot field, if one was set. if (strlen($this->honeypotFieldName) > 0) { $this->matchTagChildren[] = ['tag' => 'fieldset', 'attributes' => ['hidden' => 'hidden', 'class' => 'form-group'], 'children' => [['tag' => 'label', 'attributes' => ['for' => $this->matchTagAttributes['id'] . '_' . $this->honeypotFieldName], 'children' => [['text' => 'Please leave this field empty!']]], ['tag' => 'input', 'attributes' => ['type' => 'text', 'id' => $this->matchTagAttributes['id'] . '_' . $this->honeypotFieldName, 'class' => 'form-control', 'name' => $this->honeypotFieldName, 'value' => "", 'placeholder' => ucwords($this->honeypotFieldName)]]]]; } // Add captcha field, if one was set. if ($this->hasCaptcha === true) { $this->matchTagChildren[] = ['tag' => 'fieldset', 'attributes' => ['class' => 'form-group'], 'children' => [['tag' => 'label', 'attributes' => ['for' => $this->matchTagAttributes['id'] . '__captcha'], 'children' => [['text' => \Session::get('htmlBuilder.formBuilder.captcha.' . $this->requestObject . '.question')], ['tag' => 'sup', 'children' => [['text' => '*']]]]], ['tag' => 'input', 'attributes' => ['type' => 'text', 'id' => $this->matchTagAttributes['id'] . '__captcha', 'aria-describedby' => $this->matchTagAttributes['id'] . '__captcha_helpText', 'class' => 'form-control', 'required' => 'required', 'name' => '_captcha', 'value' => "", 'placeholder' => 'Please solve the calculation stated above.']], ['tag' => 'div', 'attributes' => ['class' => 'text-muted small', 'id' => $this->matchTagAttributes['id'] . '__captcha_helpText'], 'children' => [['text' => 'This is required to protect this form against exploitation by bots.']]]]]; } }
protected function generateMatcher() { parent::generateMatcher(); if ($this->labelMode === 'after' || $this->labelMode === 'before') { $this->labelMatcher['children'][0]['text'] = ' ' . $this->labelMatcher['children'][0]['text']; if ($this->labelMode === 'after') { array_unshift($this->labelMatcher['children'], $this->matcher[0]); } else { array_push($this->labelMatcher['children'], $this->matcher[0]); } $this->matcher[0] = ['tag' => 'label', 'children' => $this->labelMatcher['children']]; } if (isset($this->errorMatcher) && count($this->errorMatcher) > 0) { array_unshift($this->matcher, $this->errorMatcher); } if ($this->labelMode === 'bound' && isset($this->labelMatcher) && count($this->labelMatcher) > 0) { array_unshift($this->matcher, $this->labelMatcher); } if (isset($this->helpTextMatcher) && count($this->helpTextMatcher) > 0) { array_push($this->matcher, $this->helpTextMatcher); } if (isset($this->wrapperMatcher) && count($this->wrapperMatcher) > 0) { $this->wrapperMatcher['children'] = $this->matcher; $this->matcher = [$this->wrapperMatcher]; } }