Comments: on this page. Click to read or post your own.

Class FileField

Description

Represents a file type which can be added to a form.

Automatically tries to save has_one-relations on the saved record.

Please set a validator on the form-object to get feedback about imposed filesize/extension restrictions.

CAUTION: Doesn't work in the CMS due to ajax submission, please use FileIframeField instead.

Located in /sapphire/forms/FileField.php (line 15)

Object
   |
   --ViewableData
      |
      --RequestHandlingData
         |
         --FormField
            |
            --FileField
Direct descendents
Class Description
ImageField A field that will upload attached images within the CMS through an iframe.
FileIFrameField A field that will upload files to a page for use within the CMS through an iframe.
SimpleImageField SimpleImageField provides an easy way of uploading images to Image has_one relationships.
Variable Summary
Method Summary
FileField __construct (string $name, [string $title = null], [int $value = null], [Form $form = null], [string $rightTitle = null], [string $folderName = null])
void Field ()
int getAllowedMaxFileSize ([string $ext = null])
string getFolderName ()
void saveInto ( $record)
void setAllowedExtensions (array $rules)
void setAllowedMaxFileSize (unknown_type $rules)
void setFolderName (string $folderName)
void validate ( $validator)
void Value ()
Variables
array $allowedExtensions = array() (line 37)
  • var:

    Collection of extensions. Extension-names are treated case-insensitive.

    Example:

    1.      array("jpg","GIF")

  • access: public

Redefined in descendants as:
array $allowedMaxFileSize = array() (line 24)

Restrict filesize for either all filetypes or a specific extension, with extension-name as array-key and the size-restriction in bytes as array-value.

  • access: public
string $folderName = 'Uploads' (line 64)

Partial filesystem path relative to /assets directory.

Defaults to 'Uploads'.

  • access: protected
boolean $relationAutoSetting = true (line 47)

Flag to automatically determine and save a has_one-relationship on the saved record (e.g. a "Player" has_one "PlayerImage" would trigger saving the ID of newly created file into "PlayerImageID" on the record).

  • access: public
Upload $upload (line 56)

Upload object (needed for validation and actually moving the temporary file created by PHP).

  • access: protected

Inherited Variables

Inherited from FormField

FormField::$containerFieldSet
FormField::$description
FormField::$disabled
FormField::$dontEscape
FormField::$extraClass
FormField::$extraClasses
FormField::$form
FormField::$leftTitle
FormField::$message
FormField::$messageType
FormField::$name
FormField::$readonly
FormField::$rightTitle
FormField::$tabIndex
FormField::$title
FormField::$value

Inherited from RequestHandlingData

RequestHandlingData::$allowed_actions
RequestHandlingData::$request
RequestHandlingData::$url_handlers

Inherited from ViewableData

ViewableData::$casting
ViewableData::$castingHelperPair_cache
ViewableData::$customisedObj
ViewableData::$failover
ViewableData::$iteratorPos
ViewableData::$iteratorTotalItems
ViewableData::$namedAs
ViewableData::$parent
ViewableData::$_natural_cache
ViewableData::$_object_cache
ViewableData::$_xml_cache

Inherited from Object

Object::$builtInMethods
Object::$class
Object::$classConstructed
Object::$extensions
Object::$extension_instances
Object::$extraMethods
Object::$extraStatics
Object::$statics
Object::$static_cached
Methods
Constructor __construct (line 76)

Create a new file field.

FileField __construct (string $name, [string $title = null], [int $value = null], [Form $form = null], [string $rightTitle = null], [string $folderName = null])
  • string $name: The internal field name, passed to forms.
  • string $title: The field label.
  • int $value: The value of the field.
  • Form $form: Reference to the container form
  • string $rightTitle: Used in SmallFieldHolder() to force a right-aligned label
  • string $folderName: Folder to upload files to

Redefinition of:
FormField::__construct()
Create a new field.
Field (line 83)
  • access: public
void Field ()

Redefinition of:
FormField::Field()
Returns the form field - used by templates.

Redefined in descendants as:
getAllowedExtensions (line 177)
  • access: public
array getAllowedExtensions ()
getAllowedMaxFileSize (line 143)

Get maximum file size for all or specified file extension.

Falls back to the default filesize restriction ('*') if the extension was not found.

  • return: Filesize in bytes (0 means no filesize set)
  • access: public
int getAllowedMaxFileSize ([string $ext = null])
  • string $ext
getFolderName (line 203)
  • access: public
string getFolderName ()
saveInto (line 104)
  • access: public
void saveInto ( $record)

Redefinition of:
FormField::saveInto()
Method to save this form field into the given data object.

Redefined in descendants as:
setAllowedExtensions (line 184)
  • access: public
void setAllowedExtensions (array $rules)
  • array $rules
setAllowedMaxFileSize (line 164)

Set filesize maximums (in bytes).

Automatically converts extensions to lowercase for easier matching.

Example:

  1.  array('*' => 200'jpg' => 1000)

  • access: public
void setAllowedMaxFileSize (unknown_type $rules)
  • unknown_type $rules
setFolderName (line 196)
  • access: public
void setFolderName (string $folderName)
  • string $folderName
validate (line 207)
  • access: public
void validate ( $validator)
  • $validator

Redefinition of:
FormField::validate()
Validation Functions for each field type by default formfield doesnt have a validation function
Value (line 131)
  • access: public
void Value ()

Redefinition of:
FormField::Value()
Returns the field value - used by templates.

Inherited Methods

Inherited From FormField

FormField::__construct()
FormField::addExtraClass()
FormField::attrName()
FormField::attrTitle()
FormField::attrValue()
FormField::createTag()
FormField::dataValue()
FormField::debug()
FormField::describe()
FormField::extraClass()
FormField::Field()
FormField::FieldHolder()
FormField::forTemplate()
FormField::getForm()
FormField::getTabIndex()
FormField::getTabIndexHTML()
FormField::hasClass()
FormField::hasData()
FormField::id()
FormField::isComposite()
FormField::isDisabled()
FormField::isReadonly()
FormField::jsValidation()
FormField::LeftTitle()
FormField::Link()
FormField::Message()
FormField::MessageType()
FormField::Name()
FormField::name_to_label()
FormField::performDisabledTransformation()
FormField::performReadonlyTransformation()
FormField::removeExtraClass()
FormField::Required()
FormField::RightTitle()
FormField::rootFieldSet()
FormField::saveInto()
FormField::setContainerFieldSet()
FormField::setDisabled()
FormField::setError()
FormField::setForm()
FormField::setLeftTitle()
FormField::setName()
FormField::setReadonly()
FormField::setRightTitle()
FormField::setTabIndex()
FormField::setTitle()
FormField::setValue()
FormField::SmallFieldHolder()
FormField::Title()
FormField::transform()
FormField::Type()
FormField::validate()
FormField::Value()

Inherited From RequestHandlingData

RequestHandlingData::checkAccessAction()
RequestHandlingData::getRequest()
RequestHandlingData::handleRequest()
RequestHandlingData::httpError()

Inherited From ViewableData

ViewableData::ATT_val()
ViewableData::BaseHref()
ViewableData::buildCastingHelperCache()
ViewableData::cachedCall()
ViewableData::castingHelper()
ViewableData::castingHelperPair()
ViewableData::castingObjectCreator()
ViewableData::castingObjectCreatorPair()
ViewableData::CSSClasses()
ViewableData::CurrentMember()
ViewableData::CurrentPage()
ViewableData::customise()
ViewableData::Debug()
ViewableData::defineMethods()
ViewableData::escapeTypeForField()
ViewableData::Even()
ViewableData::EvenOdd()
ViewableData::First()
ViewableData::FirstLast()
ViewableData::getField()
ViewableData::getIterator()
ViewableData::getXMLValues()
ViewableData::hasField()
ViewableData::HasPerm()
ViewableData::hasValue()
ViewableData::i18nLocale()
ViewableData::IsAjax()
ViewableData::iteratorProperties()
ViewableData::JS_val()
ViewableData::Last()
ViewableData::Me()
ViewableData::Middle()
ViewableData::MiddleString()
ViewableData::obj()
ViewableData::Odd()
ViewableData::Pos()
ViewableData::RAW_val()
ViewableData::renderWith()
ViewableData::SecurityID()
ViewableData::setCustomisedObj()
ViewableData::setField()
ViewableData::SQL_val()
ViewableData::ThemeDir()
ViewableData::Top()
ViewableData::TotalItems()
ViewableData::val()
ViewableData::XML_val()
ViewableData::__get()
ViewableData::__isset()
ViewableData::__set()

Inherited From Object

Object::__construct()
Object::addMethodsFrom()
Object::addStaticVars()
Object::addWrapperMethod()
Object::add_extension()
Object::allMethodNames()
Object::buildMethodList()
Object::cacheToFile()
Object::cacheToFileWithArgs()
Object::create()
Object::createMethod()
Object::defineMethods()
Object::exists()
Object::extend()
Object::extInstance()
Object::getCustomClass()
Object::hasExtension()
Object::hasMethod()
Object::invokeWithExtensions()
Object::is_a()
Object::loadCache()
Object::parentClass()
Object::sanitiseCachename()
Object::saveCache()
Object::set_stat()
Object::set_uninherited()
Object::stat()
Object::strong_create()
Object::uninherited()
Object::useCustomClass()
Object::__call()
Object::__toString()
blog comments powered by Disqus

Documentation generated on Sun, 19 Oct 2008 06:40:56 +1300 by phpDocumentor 1.3.2