Detailed description of xml application in the joomla form. There are basically fixed formats for use. here we will not talk about the application of xml in creating forms. the role of the form is self-evident. there are forms in the module configuration, and forms in the component are basically in fixed format. here we will not talk about the application of xml in the form creation. the role of forms is self-evident. there are forms in the module configuration and forms in the component. the parameter settings in the configuration here are the forms generated by xml, which is much easier than directly creating forms, before editing the document form, let's take a look at the type of the form element. joomla provides multiple forms element styles.
The code is as follows:
// Generate the calendar time
// Obtain the unit List
// List of other component units
// Editor selection list
// File list html indicates that the display extension is html
// Folder list
// Hide the domain
Unclassified
China
USA
// Password
// Single answer
No
Yes
// Unit selection
// Horizontal line
// SQL Generation list
// Text box
// No style for text fields
// The text field has a style
// Generate the time zone list
Some generated elements are provided above. but how to use them? First, we create a form. xml file in the models folder of the component.
The code is as follows:
Here there is only one hidden element. In fact, we can create more elements, that is, the above generated element types. of course, we can also customize them. here, addpath is the custom element type, the location is in the created elements folder. the above is built-in. the following types are defined here.
The code is as follows:
// Custom control
// Convert an array to a list without writing a subscript starting from 0
// Whether to generate a single choice
// Upload control
// Check the array
// Unlimited classification. Note that the parent class of section is 0.
Using metadata, you can access view.html. php in your view folder under the viewsfolder by adding the following statement:
The code is as follows:
$ Form = new JParameter ('', JPATH_COMPONENT.DS. 'models'. DS. 'form. XML ');
$ Form-> set ('M1 ', 'default ');
$ Html = $ form-> render ('Details', 'html'); // details is an array of element names
$ This-> assignRef ('html', $ html );
The second sentence above is a value assignment. assigning values to hidden fields is equivalent to the value in editing. The third sentence is to output the form html to the template. details is the array name of element names, the generated m1 name is details [m1], followed by form. php calls are as follows:
The code is as follows:
This form is generated. this method is easier to modify the style or content than to directly write the form element. you only need to modify the xml file. in joomla2.5, basically, this method is implemented in this way, but the changes are relatively large, and the syntax of xml files is quite different. xml allows you to call the form elements in other components.
These types of form elements can be used in template configuration parameters and module parameters. in particular, you can extend the style of form elements by yourself. you can define other style types completely, I have defined several commonly used styles that are not provided with built-in functions, such as array conversion list, array conversion check, and unlimited classification. the type here is actually the JElement class of the api. for the source files, see libraries \ joomla \ html \ parameter \ element, here, how to write custom form elements? here is an example or reference to the source file. the file name is M. php, the type is custom. call method
The code is as follows:
// Custom display
//
Defined ('_ JEXEC') or die ('restricted access ');
Class JElementCustom extends JElement {
Var $ _ name = 'custom ';
Function fetchElement ($ name, $ value, & $ node, $ control_name ){
$ Html = < Custom
EOF;
Return $ html;
}
}
Well, I will not talk about it more. In fact, this is just a method to create a form. if you don't like it, you can use the form element. but since joomla provides these, why don't we use them?
Download custom element: elements_jb51.rar
...