Ejemplo n.º 1
0
 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);
 }
Ejemplo n.º 2
0
 protected function applyTagMethods2MatcherData()
 {
     parent::applyTagMethods2MatcherData();
     foreach ($this->tagParameters as $optionType => $optionValue) {
         switch ($optionType) {
             // Change wrapping accordingly.
             case 'wrap':
                 if ($optionValue === false) {
                     unset($this->wrapperMatcher);
                 }
                 // TODO: else if other wrapper -> modify $this->wrapperMatcher accordingly.
                 break;
             case 'options':
                 break;
                 // Per default we assume the methodName is a HTML-attribute.
             // Per default we assume the methodName is a HTML-attribute.
             default:
                 $this->matchTagAttributes[$optionType] = $optionValue;
         }
     }
     // Apply changes required by methods set on the Form::open call
     if (isset($this->formTemplate['methods']) && count($this->formTemplate['methods']) > 0) {
         foreach ($this->formTemplate['methods'] as $key => $methodData) {
             switch ($methodData['name']) {
                 case 'errors':
                     if (isset($methodData['parameters'][0][$this->matchTagAttributes['name']])) {
                         $this->tagMethod2Matcher_errors($methodData['parameters'][0][$this->matchTagAttributes['name']]);
                     }
                     break;
                 case 'rules':
                     if (isset($methodData['parameters'][0][$this->matchTagAttributes['name']])) {
                         $this->tagMethod2Matcher_rules($methodData['parameters'][0][$this->matchTagAttributes['name']]);
                     }
                     break;
                 case 'values':
                     if (isset($methodData['parameters'][0][$this->matchTagAttributes['name']])) {
                         if ($this->tag === 'input') {
                             if ($this->matchTagAttributes['type'] === 'checkbox' || $this->matchTagAttributes['type'] === 'radio') {
                                 if ($this->matchTagAttributes['value'] === $methodData['parameters'][0][$this->matchTagAttributes['name']]) {
                                     $this->tagMethod2Matcher_checked(true);
                                 }
                             } else {
                                 $this->matchTagAttributes['value'] = $methodData['parameters'][0][$this->matchTagAttributes['name']];
                             }
                         } else {
                             if ($this->tag === 'textarea') {
                                 $this->tagMethod2Matcher_content($methodData['parameters'][0][$this->matchTagAttributes['name']]);
                             }
                         }
                     }
                     break;
             }
         }
     }
 }
Ejemplo n.º 3
0
 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.']]]]];
     }
 }