Framework  3.9
FileUploadFieldRenderer Class Reference

Field renderer for file upload data fields. More...

+ Inheritance diagram for FileUploadFieldRenderer:
+ Collaboration diagram for FileUploadFieldRenderer:

Public Member Functions

 FileUploadFieldRenderer (&$form, $field, $label, $handler)
 
 renderField ($field)
 FieldRenderers must override this method to provide the HTML implementation of the control used to edit the field. More...
 
 renderReadOnly ($field)
 
 preProcess ($field="")
 FieldRenderers can override this method to provide behavior that occurs prior to the saving of the parent form's target object to the database. More...
 
 required ($message="")
 
- Public Member Functions inherited from FieldRenderer
 FieldRenderer ($parent)
 Constructor. More...
 
 _printLabel ($field, $colspan=1, $styles="", $annotation="")
 Internal method to generate the HTML for the field label. More...
 
 _getLabel ($field, $addSuffix=true)
 
 _startField ($field, $styles="")
 Internal method to generate the starting HTML for the field (including the label) More...
 
 _endField ($field)
 Internal method to generate the closing HTML for the field. More...
 
 addValidatorsToForm ($field, $required=false)
 This method is called by the AutoForm to add any default input validators that are required by the FieldRenderer. More...
 
 addSearchValidatorsToForm ($field, $mode, $required=false)
 For SearchForm, the validator field needs to match the name tag in the form which is in the format field:mode. More...
 
 formatName ($item, $name)
 Formats the given DataItem based on the supplied format string. More...
 
 renderScript ($field)
 FieldRenderers can override this method to provide any Javascript that their control requires for an edit form. More...
 
 renderSearchScript ($field, $mode)
 FieldRenderers can override this method to provide any Javascript that the control requires when being used in a search form. More...
 
 renderSearchField ($field, $mode)
 FieldRenderers must override this method to provide the HTML implementation of the control displayed for the field in a search form. More...
 
 renderOnSubmitHandler ($field)
 FieldRenderers can override this method to provide any Javascript that must be executed when the form is submitted on the client. More...
 
 postProcess ($field="")
 FieldRenderers can override this method to provide behavior that occurs after the parent form's target object has been saved to the database. More...
 

Public Attributes

 $handler
 
 $size
 
 $field
 
 $accept
 
- Public Attributes inherited from FieldRenderer
 $parent = null
 
 $labelSuffix = ""
 
 $colspan = 1
 
 $annotateBefore = false
 
 $annotateNextLine = true
 
 $hideLabel = false
 
 $onPreProcess = null
 callback hook for processing prior to saving the form's data object - individual renderers may override with custom processing More...
 
 $onPostProcess = null
 callback hook for processing after saving the form's data object - individual renderers may override with custom processing More...
 

Detailed Description

Field renderer for file upload data fields.

Renders using the browser's standard file upload control. The programmer must supply a callback handler to manage the file upload process, as upload logic can vary greatly from application to application.

Definition at line 47 of file file_upload_field_renderer.inc.

Member Function Documentation

◆ FileUploadFieldRenderer()

FileUploadFieldRenderer::FileUploadFieldRenderer ( $form,
  $field,
  $label,
  $handler 
)

Definition at line 54 of file file_upload_field_renderer.inc.

55  {
56  $this->FieldRenderer($form);
57 
58  $this->handler = $handler;
59  $this->field = $field;
60 
61  if ($form->data->hasField($field))
62  {
63  $form->override($field, $label, $this);
64  }
65  else
66  {
67  $form->add($this, $field);
68  $form->overrides[$field]['label'] = $label;
69  }
70 
71  $size = 40;
72  }
FieldRenderer($parent)
Constructor.

◆ preProcess()

FileUploadFieldRenderer::preProcess (   $field = "")

FieldRenderers can override this method to provide behavior that occurs prior to the saving of the parent form's target object to the database.

For example, the FileUploadFieldRenderer overrides this method to process the uploading of the file and then store the location in the associated field in the target object.

Parameters
string$fieldthe field name

Reimplemented from FieldRenderer.

Definition at line 92 of file file_upload_field_renderer.inc.

93  {
94  call_user_func($this->handler, $field, $this->parent->data);
95  }

◆ renderField()

FileUploadFieldRenderer::renderField (   $field)

FieldRenderers must override this method to provide the HTML implementation of the control used to edit the field.

Parameters
string$fieldthe field name

Reimplemented from FieldRenderer.

Definition at line 74 of file file_upload_field_renderer.inc.

75  {
76  $this->_startField($field);
77 
78  $accept = $this->accept ? " accept='{$this->accept}'" : "";
79  echo "<input id='{$this->parent->id}_{$field}' type='file' name='$field' value='".$this->parent->data->get($field)."' size='{$this->size}'{$accept}>";
80  $this->_endField($field);
81  }
_startField($field, $styles="")
Internal method to generate the starting HTML for the field (including the label)
_endField($field)
Internal method to generate the closing HTML for the field.

◆ renderReadOnly()

FileUploadFieldRenderer::renderReadOnly (   $field)

Definition at line 83 of file file_upload_field_renderer.inc.

84  {
85  $this->_startField($field);
86 
87  echo $this->parent->data->get($field);
88 
89  $this->_endField($field);
90  }

◆ required()

FileUploadFieldRenderer::required (   $message = "")

Definition at line 97 of file file_upload_field_renderer.inc.

98  {
99  $this->parent->validator->add(new RequiredFileValidator($this->field, $this->label, $message));
100  }

Member Data Documentation

◆ $accept

FileUploadFieldRenderer::$accept

Definition at line 52 of file file_upload_field_renderer.inc.

◆ $field

FileUploadFieldRenderer::$field

Definition at line 51 of file file_upload_field_renderer.inc.

◆ $handler

FileUploadFieldRenderer::$handler

Definition at line 49 of file file_upload_field_renderer.inc.

◆ $size

FileUploadFieldRenderer::$size

Definition at line 50 of file file_upload_field_renderer.inc.


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