Framework  3.9
SelectFieldViewSourceRenderer Class Reference

SelectFieldViewSourceRenderer: Renders the specified list of options as a dropdown select box with a View button to the right which would display specified popup preview. More...

Inherits SelectFieldRenderer.

Public Member Functions

 SelectFieldViewSourceRenderer (&$form, $field, $label, $options, $callback)
 
 renderScript ($field)
 
 _endField ($field)
 

Public Attributes

 $buttonLabel
 
 $field
 
 $callback
 

Detailed Description

SelectFieldViewSourceRenderer: Renders the specified list of options as a dropdown select box with a View button to the right which would display specified popup preview.

Parameters
obj$formthe AutoForm object, passed by reference
string$fieldthe name of the field defined in the dataitem class object in the datamodel folder whose value can be changed by the select item list box. This field name should match the field name in the database.
string$labelpresented on the form to the user to describe the list box
arrayoptions defined in the dataitem class object that contains the option ids and labels for the list box For example, for action_type, create array ActionTypes as follows: actionTypes = array ( 1 => "Introduction", 2 => "Investigation", 3 => "Formal Assessment" )
string$callbackjavascript function that opens the popup e.g., openMyDialog or new MyClass().openMyDialog the "()" is left off and supplied in the selection change function written by this class.

Calling script creates an instance as follows: $myFieldSelect = new SelectFieldViewSourceRenderer($form, "field name", "Label", options array, jsFunction);

The javascript function name provided must contain a call to create the modal dialog. This function receives the select field value. Example:

myJavascriptFunction(selectFieldValue) { modalPopup('myTitle', '/action/myComponent/my_modal_dialog?mySelectField=' + selectFieldValue, '400px', 'auto', true); }

Definition at line 82 of file select_field_view_source_renderer.inc.

Member Function Documentation

◆ _endField()

SelectFieldViewSourceRenderer::_endField (   $field)

Definition at line 143 of file select_field_view_source_renderer.inc.

144  {
145  $name = "view_{$field}_button";
146 
147  echo "&nbsp;<button id=\"$name\" name=\"$name\" onclick=\"{$this->parent->id}_{$field}_preview(); return false;\" class=\"button\">View {$this->buttonLabel}</button>";
148 
149  parent::_endField($field);
150  }

◆ renderScript()

SelectFieldViewSourceRenderer::renderScript (   $field)

Definition at line 107 of file select_field_view_source_renderer.inc.

108  {
109  $fn = "{$this->parent->id}_{$field}";
110  $selChanged = "selChanged_" . $field;
111 
112 ?>
113 <script type="text/javascript">
114 function <?echo $fn ?>_preview()
115 {
116  var elt = document.id('<? echo $fn ?>');
117 
118  if (elt.value)
119  {
120  var dialog = <?php echo $this->callback ?>(elt.value);
121  }
122 }
123 
124 function <? echo $selChanged ?>(elt)
125 {
126  var button = document.id('view_<? echo $field ?>_button');
127  if (elt.value)
128  button.disabled = "";
129  else
130  button.disabled = "disabled";
131 }
132 
133 window.addEvent('load', function()
134 {
135  var elt = document.id('<? echo $field ?>');
136  <? echo $selChanged ?>(elt);
137  });
138 </script>
139 <?
140  }

◆ SelectFieldViewSourceRenderer()

SelectFieldViewSourceRenderer::SelectFieldViewSourceRenderer ( $form,
  $field,
  $label,
  $options,
  $callback 
)

Definition at line 89 of file select_field_view_source_renderer.inc.

90  {
91  $onChange = "selChanged_{$field}";
92  $this->field = $field;
93 
94  // If user provided ending "()" on function, remove
95  $callback = preg_replace("/\‍(*?\‍)$/", "", $callback);
96  $this->callback = $callback;
97 
98  // show none if none - overrides SelectFieldRenderer code that
99  // adds options when there are none
100  if ($options == null)
101  $options[0] = "";
102 
103  $this->SelectFieldRenderer($form, $field, $label, $options, $onChange);
104  $this->buttonLabel = $label;
105  }

Member Data Documentation

◆ $buttonLabel

SelectFieldViewSourceRenderer::$buttonLabel

Definition at line 84 of file select_field_view_source_renderer.inc.

◆ $callback

SelectFieldViewSourceRenderer::$callback

Definition at line 87 of file select_field_view_source_renderer.inc.

◆ $field

SelectFieldViewSourceRenderer::$field

Definition at line 85 of file select_field_view_source_renderer.inc.


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