Application of XML in Joomla form share _php Tutorial

Source: Internet
Author: User
Tags timezones
Basically there is a fixed format, in this not to say, here is mainly about the application of XML in the creation of forms. The role of the form is self-evident, in the module configuration there is a form, the component also has a form, where the configuration of the parameter set is the XML generated form, relative to through the direct construction of the form is convenient, Here, by editing the use of the article form, before using it, let's look at the types of form elements, which Joomla provides to generate multiple form element styles.
Copy CodeThe code is as follows:
Generate Calendar Time
Get a list of units
List of other component units
Editor selection list
File list HTML indicates display extension HTML
Folder List
Hidden fields

Not categorized
United States


Cell selection
SQL Build List
text box
Text Field no style
Text fields have styles
Generate a Time zone list

Above is a few of the generated elements provided, but how to use it, we first set up a form.xml, in the component's Models folder
Copy CodeThe code is as follows:

There's only one hidden element here. In fact, we can build more elements, that is, the above types of generated elements, of course, can also be customized, here Addpath is the custom element type, the location is in the elements folder of the building, the top is built, the author defines the following types here
Copy CodeThe code is as follows:
Custom controls
Array converted to list do not write subscript starting from 0
Whether the build is a single selection
Uploading controls
Array check
Infinite Classification Note Add Section parent class is 0

Using the method above, the element's customization file is provided in the download. Then we are in the Views folder below your view folder in the view.html.php add the following statement
Copy CodeThe code is as follows:
$form = new Jparameter ("', jpath_component. DS. ' Models '. DS. ' Form.xml ');
$form->set (' M1 ', ' default value ');
$html = $form->render (' Details ', ' HTML '); Details is the element an array group
$this->assignref (' HTML ', $html);

The second sentence above is the assignment, the hidden field assignment, equivalent to the editor inside the value, the 34th sentence is the form HTML output to the template, details is the element name array name, the generated M1 name is DETAILS[M1], and then form.php called the following
Copy CodeThe code is as follows:

Such a form is generated, relative to the direct write form elements, this method is easier to modify the style or content, modify only need to change the XML file, in the joomla2.5 version, basically is implemented in this way, but the change is relatively large, the XML file is very different, Through XML, it is possible to invoke form elements within other components.

These types of form elements in the template configuration parameters, module parameters are available, in particular, you can extend the form elements of the style, you can define the other style, the author defines the more commonly used but built-in not provided, such as array conversion list, array conversion check, Styles such as infinite classification. Here is the type is actually the API Jelement class, inside the source file can refer to Libraries\joomla\html\parameter\element, Customize the form element here how to write it here to give an example or reference source file to understand, the file name custom.php, type is custom, call method
Copy CodeThe 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
return $html;

Okay, not much, but it's just a way to build a form, and if you don't like it, you can use the form element, but since Joomla provides these, why don't we?
Download the custom element: Elements_jb51.rar 325610.html true techarticle Basically there is a fixed format, there is not much to say, here is mainly about the application of XML in the creation of the form. The function of the form is self-evident, there are forms in the module configuration, there are also forms inside the components ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.