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...")
 
(Marked this version for translation)
(4 intermediate revisions by 4 users not shown)
Line 1: Line 1:
 +
<noinclude><languages /></noinclude>
 +
<translate><!--T:1-->
 +
* '''type''' (mandatory) must be ''file''.</translate>
 +
<translate><!--T:2-->
 +
* '''name''' (mandatory) is the unique name of the field.</translate>
 +
<translate><!--T:3-->
 +
* '''label''' (mandatory) (translatable) is the descriptive title of the field.</translate>
 +
<translate><!--T:4-->
 +
* '''description''' (optional) (translatable) is text that will be shown as a tooltip when the user moves the mouse over the drop-down box.</translate>
 +
<translate><!--T:5-->
 +
* '''default''' (optional) (not translatable) is the default value, but doesn't mean much for a file.</translate>
 +
<translate><!--T:6-->
 +
* '''size''' (optional) is the width of the file box in characters.</translate>
 +
<translate><!--T:7-->
 +
* [http://www.w3schools.com/tags/att_input_accept.asp '''accept'''] (optional) Tells the browser what MIME types your form will allow to be uploaded.</translate>
 +
<translate><!--T:8-->
 +
* '''class''' (optional) is a CSS class name for the HTML form field.</translate>
 +
<translate><!--T:9-->
 +
* '''labelclass''' (optional) adds a CSS class for form field's label; for Joomla 2.5.4+</translate>
 +
<translate><!--T:10-->
 +
* '''disabled''' (optional)  HTML equivalent attribute</translate>
 +
<translate><!--T:11-->
 +
* '''onchange''' (optional)  HTML equivalent attribute (javascript use)</translate>
 +
<translate><!--T:12-->
 +
* '''required''' (optional)  For Joomla form validating it to be filled in</translate>
 +
<translate><!--T:13-->
 +
* '''validate''' (optional)  Whether to Joomla validate the field according to rules</translate>
 +
<translate><!--T:14-->
 +
* '''showon''' (optional)  Allows you to hide the field based on the value(s) of another field; for Joomla 3.2.4+</translate>
  
{{incomplete}}{{review}}
+
<translate><!--T:15-->
{{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]].}}
 
 
 
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.
 
* [http://www.w3schools.com/tags/att_input_accept.asp '''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:'''
 
'''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.
+
When using the file input type you should always add the attribute enctype="multipart/form-data" to your form tag. Otherwise, the uploaded files will not be attached correctly.</translate>
 +
<translate><!--T:16-->
 +
'''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.</translate>
  
'''Note 2:'''
+
<translate><!--T:17-->
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:</translate>
Example XML field definition:
 
  
<source lang="xml"><field name="myfilevalue" type="file" label="Enter some text" description="Choose an image from your computer with maximum 100KB" size="10" accept="image/*" /></source>
+
<source lang="xml">
 +
<field name="myfilevalue" type="file" label="Enter some text" description="Choose an image from your computer with maximum 100KB" size="10" accept="image/*" />
 +
</source>
  
 +
<translate>=== See also === <!--T:18--></translate>
 +
<translate><!--T:19-->
 +
* [[S:MyLanguage/Standard form field types|List of standard form field types]]</translate>
  
=== See also ===
+
<noinclude>
* [[Media_form_field_type]]
+
<translate>
* [[Standard form field types|List of standard form field types]]
+
<!--T:20-->
[[Category:Standard form field types]]</noinclude>
+
[[Category:Standard form field types]]
 +
[[Category:Form fields]]
 +
[[Category:Development]]
 +
</translate>
 +
</noinclude>

Revision as of 08:22, 15 August 2015

Other languages:
Deutsch • ‎English • ‎Nederlands • ‎español • ‎français
  • type (mandatory) must be file.
  • name (mandatory) is the unique name of the field.
  • label (mandatory) (translatable) is the descriptive title of the field.
  • description (optional) (translatable) is text that will be shown as a tooltip when the user moves the mouse over the drop-down box.
  • default (optional) (not translatable) is the default value, but doesn't mean much for a file.
  • 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.
  • labelclass (optional) adds a CSS class for form field's label; for Joomla 2.5.4+
  • disabled (optional) HTML equivalent attribute
  • onchange (optional) HTML equivalent attribute (javascript use)
  • required (optional) For Joomla form validating it to be filled in
  • validate (optional) Whether to Joomla validate the field according to rules
  • showon (optional) Allows you to hide the field based on the value(s) of another field; for Joomla 3.2.4+

Note: When using the file input type you should always add the attribute enctype="multipart/form-data" to your form tag. 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[edit]