Framework  3.9
TemplateFormLayout Class Reference

TemplateFormLayout provides support for custom form layouts. More...

+ Inheritance diagram for TemplateFormLayout:
+ Collaboration diagram for TemplateFormLayout:

Public Member Functions

 __construct ($form, $template, $showButtons=true)
 
 startGroup ($name, $collapsible=false, $collapsed=false)
 
 endGroup ()
 
 startField ($field, $renderer, $colspan=1, $styles="")
 
 endField ($field, $renderer)
 
 printLabel ($field, $renderer, $styles="", $annotation="")
 Internal method to generate the HTML for the field label. More...
 
 startUngrouped ()
 
 endUngrouped ()
 
 startButtonLine ()
 
 endButtonLine ()
 
 errorBox ()
 
 requiredFields ($text)
 
 finalizeLayout ()
 
- Public Member Functions inherited from AutoFormLayout
 __construct ($form)
 
 getGroupClass ($name, $collapsible, $collapsed, $additionalClass="")
 
 getLabel ($field, $renderer, $addSuffix=true)
 
 getLabelID ($field)
 

Public Attributes

 $template
 
 $output
 
 $showButtons = true
 
- Public Attributes inherited from AutoFormLayout
 $form
 
 $externalErrorBox = false
 Flag indicating whether the error box should be rendered inside the form grouping. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from AutoFormLayout
static create ($type, $form)
 

Detailed Description

TemplateFormLayout provides support for custom form layouts.

Author
andy

Definition at line 1008 of file auto_form_layout.inc.

Constructor & Destructor Documentation

◆ __construct()

TemplateFormLayout::__construct (   $form,
  $template,
  $showButtons = true 
)

Definition at line 1014 of file auto_form_layout.inc.

1015  {
1016  trace("Using form template {$template}", 3);
1017  $this->template = file_get_contents($template);
1018  $this->showButtons = $showButtons;
1019  parent::__construct($form);
1020  }
trace($msg, $lvl=3, $callStack=null)
Send output to the trace log.
Definition: functions.inc:1010

Member Function Documentation

◆ endButtonLine()

TemplateFormLayout::endButtonLine ( )

Reimplemented from AutoFormLayout.

Definition at line 1116 of file auto_form_layout.inc.

1117  {
1118  if ($this->showButtons)
1119  {
1120  $this->output .= ob_get_contents();
1121  }
1122  ob_end_clean();
1123 
1124  $this->output .= "</div><br/>";
1125  }

◆ endField()

TemplateFormLayout::endField (   $field,
  $renderer 
)

Reimplemented from AutoFormLayout.

Definition at line 1041 of file auto_form_layout.inc.

1042  {
1043  $fieldContent = ob_get_contents();
1044 
1045  ob_end_clean();
1046 
1047  if ($renderer->parent->showAnnotations && !$renderer->annotateBefore && $renderer->parent->annotations[$field])
1048  {
1049  if ($renderer->annotateNextLine)
1050  {
1051  $fieldContent .= "<br/>";
1052  }
1053  else
1054  {
1055  $fieldContent .= "&nbsp;&nbsp;";
1056  }
1057 
1058  $fieldContent .= $renderer->parent->annotations[$field];
1059  }
1060 
1061  $this->template = str_replace("{".$field."}", $fieldContent, $this->template);
1062  }

◆ endGroup()

TemplateFormLayout::endGroup ( )

Reimplemented from AutoFormLayout.

Definition at line 1028 of file auto_form_layout.inc.

1029  {
1030  $this->endUngrouped();
1031  }

◆ endUngrouped()

TemplateFormLayout::endUngrouped ( )

Reimplemented from AutoFormLayout.

Definition at line 1103 of file auto_form_layout.inc.

1104  {
1105  }

◆ errorBox()

TemplateFormLayout::errorBox ( )

Reimplemented from AutoFormLayout.

Definition at line 1127 of file auto_form_layout.inc.

1128  {
1129  $this->output .= "<div id='{$this->form->id}__error' class='error' style='display: ".($this->form->msg ? 'table-cell' : 'none')."'>{$this->form->msg}</div>\n";
1130  }

◆ finalizeLayout()

TemplateFormLayout::finalizeLayout ( )

Reimplemented from AutoFormLayout.

Definition at line 1137 of file auto_form_layout.inc.

1138  {
1139  // Clear any unmapped fields
1140  foreach($this->form->data->getFields() as $field => $type)
1141  {
1142  $this->template = str_replace(array("{{$field}}", "{label:{$field}}"), array("", ""), $this->template);
1143  }
1144 
1145  $this->output = str_replace("{FORM}", $this->template, $this->output);
1146  echo $this->output;
1147  }

◆ printLabel()

TemplateFormLayout::printLabel (   $field,
  $renderer,
  $styles = "",
  $annotation = "" 
)

Internal method to generate the HTML for the field label.

Parameters
string$fieldthe field name
int$colspanthe number of columns to span
string$stylesoptional special styles that need to be applied
string$annotationannotation text for the field

Reimplemented from AutoFormLayout.

Definition at line 1072 of file auto_form_layout.inc.

1073  {
1074  if ($renderer->hideLabel && !$annotation) return;
1075 
1076  $label = $this->getLabel($field, $renderer);
1077 
1078  $labelHTML = "";
1079 
1080  if (!$renderer->hideLabel)
1081  {
1082  $labelHTML .= "<label id='".$this->getLabelID($field)."' for='$field'";
1083  if ($renderer->parent->labelCSS) $labelHTML .= " class='{$renderer->parent->labelCSS}'";
1084  if ($styles) $labelHTML .= " style='$styles'";
1085 
1086  $labelHTML .= ">$label</label> ";
1087  }
1088 
1089  $labelHTML .= "$annotation\n";
1090 
1091  $this->template = str_replace("{label:".$field."}", $labelHTML, $this->template);
1092  }
getLabel($field, $renderer, $addSuffix=true)

◆ requiredFields()

TemplateFormLayout::requiredFields (   $text)

Reimplemented from AutoFormLayout.

Definition at line 1132 of file auto_form_layout.inc.

1133  {
1134  $this->output .= "<p class='required_text'>{$text}</p>\n";
1135  }

◆ startButtonLine()

TemplateFormLayout::startButtonLine ( )

Reimplemented from AutoFormLayout.

Definition at line 1107 of file auto_form_layout.inc.

1108  {
1109  $this->output .= "<br/>\n";
1110  $this->output .= " <div class='{$this->form->buttonLineCSS}' style='text-align: {$this->form->buttonAlignment}'><br/>";
1111 
1112  ob_start();
1113 
1114  }

◆ startField()

TemplateFormLayout::startField (   $field,
  $renderer,
  $colspan = 1,
  $styles = "" 
)

Reimplemented from AutoFormLayout.

Definition at line 1033 of file auto_form_layout.inc.

1034  {
1035  $annotations = ($renderer->parent->showAnnotations && $renderer->annotateBefore) ? $renderer->parent->annotations[$field] : "";
1036  $this->printLabel($field, $renderer, $styles, $annotations);
1037 
1038  ob_start();
1039  }

◆ startGroup()

TemplateFormLayout::startGroup (   $name,
  $collapsible = false,
  $collapsed = false 
)

Reimplemented from AutoFormLayout.

Definition at line 1022 of file auto_form_layout.inc.

1023  {
1024  // Groups are ignored when dealing with template form layouts
1025  $this->startUngrouped();
1026  }

◆ startUngrouped()

TemplateFormLayout::startUngrouped ( )

Reimplemented from AutoFormLayout.

Definition at line 1094 of file auto_form_layout.inc.

1095  {
1096  if (!$this->renderingForm)
1097  {
1098  $this->output .= "{FORM}";
1099  $this->renderingForm = true;
1100  }
1101  }

Member Data Documentation

◆ $output

TemplateFormLayout::$output

Definition at line 1011 of file auto_form_layout.inc.

◆ $showButtons

TemplateFormLayout::$showButtons = true

Definition at line 1012 of file auto_form_layout.inc.

◆ $template

TemplateFormLayout::$template

Definition at line 1010 of file auto_form_layout.inc.


The documentation for this class was generated from the following file: