Actions

Difference between revisions of "File form field type"

From Joomla! Documentation

(Created page with " {{incomplete}}{{review}} {{Ambox|type=notice|text=In Joomla! 1.5, form fields were parameters. For that version, you may want to use the correspo...")
 
(Remove Incomplete and review tags)
 
(One intermediate revision by one user not shown)
Line 1: Line 1:
 
{{incomplete}}{{review}}
 
 
{{Ambox|type=notice|text=In Joomla! 1.5, [[Form field|form fields]] were [[Parameter|parameters]]. For that version, you may want to use the corresponding [[Text parameter type]].}}
 
{{Ambox|type=notice|text=In Joomla! 1.5, [[Form field|form fields]] were [[Parameter|parameters]]. For that version, you may want to use the corresponding [[Text parameter type]].}}
  
Line 20: Line 18:
  
 
'''Note:'''
 
'''Note:'''
You should always add the attribute enctype="multi-part/form-data" to your form tag when using the file input type. Otherwise, the uploaded files will not be attached correctly.
+
You should always add the attribute enctype="multipart/form-data" to your form tag when using the file input type. Otherwise, the uploaded files will not be attached correctly.
  
 
'''Note 2:'''
 
'''Note 2:'''

Latest revision as of 04:05, 7 February 2013

Intro: todo

  • type (mandatory) must be file.
  • name (mandatory) is the unique name of the field.
  • label (mandatory) (translatable) is the descriptive title of the field.
  • default (optional) (not translatable) is the default value, but doesn't mean much for a file.
  • description (optional) (translatable) is text that will be shown as a tooltip when the user moves the mouse over the drop-down box.
  • size (optional) is the width of the file box in characters.
  • accept (optional) Tells the browser what MIME types your form will allow to be uploaded.
  • class (optional) is a CSS class name for the HTML form field.
  • disabled (optional) HTML equivalent attribute
  • onchange (optional) HTML equivalent attribute
  • required (optional) For Joomla form validating it to be filled in
  • validate (optional) Whether to Joomla validate the field according to rules
  • onchange (optional) HTML equivalent attribute (javascript use)

Note: You should always add the attribute enctype="multipart/form-data" to your form tag when using the file input type. Otherwise, the uploaded files will not be attached correctly.

Note 2: You can put a soft limit file size by adding a hidden field with name="MAX_FILE_SIZE" and value the maximum allowed bytes which is handled by php, but you must also handle it in your code with or without it. Example XML field definition:

<field name="myfilevalue" type="file" label="Enter some text" description="Choose an image from your computer with maximum 100KB" size="10" accept="image/*" />


See also