Joomla! 1.5 form Implementation Method

Source: Internet
Author: User

Original article: joomla! 1.5 form Implementation Method

Joomla! In 1.5, jparameter not only provides an XML and INI File Read and access method, but also provides a render function, which is applicable to joomla! The form creation in section 1.5 provides great convenience. In fact, joomla! This method is widely used on the article editing page of 1.5. In this way, the separation of page elements and data is better achieved, and some form items are verified.

Let's introduce a simple joomla! 1.5 form creation. Suppose we have a component com_test. In the first step, we need to add a test. xml file in com_test/models. The content is as follows:

<?xml version="1.0" encoding="utf-8"?>
<form>
 <name>Test Form</name>
 <params group="advanced">
  <param name="show_title" type="list" default="" label="Show Title" description="Show/Hide the items title">
   <option value="">Use Global</option>
   <option value="0">No</option>
   <option value="1">Yes</option>
  </param>
  <param name="created" type="calendar" default="" label="Created Date" description="DETAILCREATED" />
  <param name="publish_up" type="calendar" default="" label="Start Publishing" description="DETAILSTART" />
  <param name="keywords" type="textarea" rows="5" cols="30" default="" label="Keywords" description="METAKEYS" />
  <param name="robots" type="text" size="20" default="" label="Robots" description="METAROBOTS" />
 </params>
</form>

In fact, this part corresponds to some or all items in this form. Our form has five items, the first is select list, the next two are dates, and the fourth keywords is a textarea, the last one is text input. After completing this process, we can implement the following code in the display function of view.html. php In the video file:

     $form = new JParameter('', JPATH_COMPONENT.DS.'models'.DS.'test.xml');
    $html=$form->render('details', 'advanced');
    $this->assignRef('html',$html);

It is very simple, and then in the view template file tmpl/Default. php:

  <form action='/index.php' method="post">
   <?php echo $this->html; ?>
   <input type="submit" value="submit">
   <input type="hidden" name="task" value="save">
   <input type="hidden" name="option" value="com_test">
  </form>

Now you can go through the http://yourdomain.com/index.php? Option = com_test & view = test. Check the source code of the browser to see what is generated.

There are many benefits to doing so. If we modify the data structure of a data table, we only need to modify the test. xml file for the interface work we are involved in, without worrying about other things.

It is really convenient to do this. What if the initial values in the form are dynamic? Leave a message if you know it. Thank you!

 

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: info-contact@alibabacloud.com 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.