In Joomla from 2.5 to be done in Class JForm to add to the convenience. Flexibility to create a form And running through the field with field preparation of standard form. I run several at Standard form field types by building takes the form of XML.

creating forms in the models folder and create a file. hello.xml model is built in as root and use the tag form to consist in the field to take the field before the main attribute like name Class Label Type Required.

com_helloworld/models/forms/hello.xml

<?xml version="1.0" encoding="utf-8"?>
<form>
        <fieldset name="hello_form">
                <field 
                        name="name" 
                        type="text"
                        class="inputbox"
                        label="Name"
                        required="true"
                />

                <field 
                        name="detail" 
                        type="textarea"
                        class="inputbox"
                        label="Detail"
                        required="true"
                        rows="5"
                />
        </fieldset>
</form>

 

- Create hello.php file in the models folder, open and code.

com_helloworld/models/hello.php

 

<?php
defined('_JEXEC') or die('Restricted access');

class HelloworldModelHello extends JModelForm 
{
       
        function getForm($data = array(), $loadData = true) 
        {
               
                $options = array('control' => 'jform', 'load_data' => $loadData);

               
                $form = $this->loadForm('com_helloworld.hello', 'hello', $options);
               
                if (empty($form)) {
                        return false;  
                }
                
                return $form;
        }

}
?>

 

Modify files in the folder view.html.php views/hello.

com_helloworld/views/hello/view.html.php

 

<?php
defined('_JEXEC') or die('Restricted access');

class HelloworldViewHello extends JViewLegacy 
{

        function display($tpl = null)
        {
                
                $this->form = $this->get('Form');
                $this->addToolbar();
                
                parent::display($tpl);
        }
        
        
       
        function addToolbar()
        {
                JToolbarHelper::save(); 
                JToolbarHelper::cancel();
        }
    
}

 

-Edit the default.php file in the tmpl.

com_helloworld/views/hello/tmpl/default.php

<?php 
defined('_JEXEC') or die('Restricted access');


JHtml::_('behavior.keepalive');
JHtml::_('behavior.tooltip');
JHtml::_('behavior.formvalidation');

?>
<script>
    Joomla.submitbutton = function(task) {
        if (task == 'cancel' || document.formvalidator.isValid(document.id('adminForm'))) {
            Joomla.submitform(task, document.getElementById('adminForm'));
        } else {
            alert('Form Invaild');
        }
    }
</script>

<form action="<?php echo JRoute::_('index.php?option=com_helloworld&c=hello'); ?>" name="adminForm" id="adminForm" method="post" class "form-validate form-horizontal">
  
    <fieldset>
        
        <?php foreach ($this->form->getFieldset('hello_form') as $field) { ?>
            <div class="control-group">
                <div class="control-label">
                    <?php echo $field->label; ?>
                </div>
                <div class="controls">
                    <?php echo $field->input; ?>
                </div>
            </div>
        <?php } ?>
        
        <input type="hidden" name="task" />
        <?php echo JHtml::_('form.token'); ?>
        
    </fieldset>
    
</form>
?>

 

Summary File:

com_helloworld/helloworld.php

com_helloworld/controllers/hello.php

com_helloworld/models/hello.php

com_helloworld/models/forms/hello.xml

com_helloworld/views/hello/view.html.php

com_helloworld/views/hello/tmpl/default.php

 

Display:

 

 

 

Chapter 10 - Saving data into database Component Development

Recent Topics
Subject
Post Reply
Open
Recent
downloading MD Watermark
By bfred Fri 04 Oct 2019 3:21 pm Board English Language
6
2378
Mon 30 Dec 2019 7:26 pm By mindphp View Topic downloading MD Watermark
Features Review : Component Mjform Advance untuk meningkatkan form atau borang untuk laman web dgn lebih baik
By abdkode Mon 22 Apr 2019 6:51 pm Board Bahasa Language
0
13363
Mon 22 Apr 2019 6:51 pm By abdkode View Topic Features Review : Component Mjform Advance untuk meningkatkan form atau borang untuk laman web dgn lebih baik
Features Review : Mhosting Components untuk mengumpul Packet hosting
By abdkode Mon 22 Apr 2019 6:50 pm Board Bahasa Language
0
4341
Mon 22 Apr 2019 6:50 pm By abdkode View Topic Features Review : Mhosting Components untuk mengumpul Packet hosting
Features Review : Components MD Gallery untuk membuat gelari dalam laman web
By abdkode Mon 22 Apr 2019 6:49 pm Board Bahasa Language
0
6926
Mon 22 Apr 2019 6:49 pm By abdkode View Topic Features Review : Components MD Gallery untuk membuat gelari dalam laman web
3 Investment Worthly in Thaland
By wannapat Tue 19 Mar 2019 4:38 pm Board Chinese Language - 简体中文
0
21245
Tue 19 Mar 2019 4:38 pm By wannapat View Topic 3 Investment Worthly in Thaland
Features Review : Plugin Addons Payment Omise untuk membuat pembayaran melalui Omise
By abdkode Mon 11 Mar 2019 6:58 pm Board Bahasa Language
0
5023
Mon 11 Mar 2019 6:58 pm By abdkode View Topic Features Review :  Plugin Addons Payment Omise untuk membuat pembayaran melalui Omise
Features Review : Memperkenalkan Mooziicart untuk Joomla
By abdkode Thu 07 Mar 2019 7:06 pm Board Bahasa Language
0
6069
Thu 07 Mar 2019 7:06 pm By abdkode View Topic Features Review : Memperkenalkan Mooziicart  untuk Joomla
Features Review : Plugin M Product Match untuk menghungkan produk dengan artikel
By abdkode Thu 07 Mar 2019 6:19 pm Board Bahasa Language
0
5579
Thu 07 Mar 2019 6:19 pm By abdkode View Topic Features Review : Plugin M Product Match untuk menghungkan produk dengan artikel
Features Review : Module MD Client History modul memapar sajarah yang telah masuk
By abdkode Tue 05 Mar 2019 7:15 pm Board Bahasa Language
0
4026
Tue 05 Mar 2019 7:15 pm By abdkode View Topic Features Review : Module MD Client History  modul memapar sajarah yang telah masuk
Features Review : Plugin M Animate Number untuk memaparkan nombor yang bergerak
By abdkode Mon 04 Mar 2019 7:02 pm Board Bahasa Language
0
4830
Mon 04 Mar 2019 7:02 pm By abdkode View Topic Features Review : Plugin M Animate Number untuk memaparkan nombor yang bergerak
Features Review : Plugin PayToRead untuk mempaparkan teks hanya sebahagian
By abdkode Mon 04 Mar 2019 7:01 pm Board Bahasa Language
0
4884
Mon 04 Mar 2019 7:01 pm By abdkode View Topic Features Review : Plugin PayToRead untuk mempaparkan teks hanya sebahagian
Features Review : Component MFacebook untuk membantu pendaftaran laman web dgn Facebook
By abdkode Mon 04 Mar 2019 6:57 pm Board Bahasa Language
0
5724
Mon 04 Mar 2019 6:57 pm By abdkode View Topic Features Review : Component MFacebook untuk membantu pendaftaran laman web dgn Facebook
Features Review : MJClone untuk mengklon laman web joomla dan backup
By abdkode Thu 28 Feb 2019 6:59 pm Board Bahasa Language
0
6294
Thu 28 Feb 2019 6:59 pm By abdkode View Topic Features Review : MJClone untuk mengklon laman web joomla dan backup
Features Review : Module Mrelated Article Specific Category untuk menyimpan sejarah lawatan
By abdkode Thu 28 Feb 2019 6:48 pm Board Bahasa Language
1
8423
Tue 27 Oct 2020 6:07 pm By prmindphp View Topic Features Review : Module Mrelated Article Specific Category untuk menyimpan sejarah lawatan
Features Review : Plugin MLinkarticle untuk menghubungkan konten artikel kepada artikel yang berkaitan
By abdkode Tue 26 Feb 2019 6:37 pm Board Bahasa Language
0
5230
Tue 26 Feb 2019 6:37 pm By abdkode View Topic Features Review : Plugin MLinkarticle untuk menghubungkan konten artikel kepada artikel yang berkaitan
Features Review : Plugin Authentication untuk login Joomla dengan phpBB
By abdkode Tue 26 Feb 2019 6:29 pm Board Bahasa Language
0
7185
Tue 26 Feb 2019 6:29 pm By abdkode View Topic Features Review : Plugin Authentication untuk login Joomla dengan phpBB
Features Review : untuk menghasilkan link memuat naik video pada artikel, Joomla 2.5, 3.x
By abdkode Tue 26 Feb 2019 5:26 pm Board Bahasa Language
0
4997
Tue 26 Feb 2019 5:26 pm By abdkode View Topic Features Review : untuk menghasilkan link memuat naik video pada artikel, Joomla 2.5, 3.x
Features Review : Plugin MVDO untuk memuat naik video Youtube dan Clipmass
By abdkode Mon 25 Feb 2019 5:54 pm Board Bahasa Language
0
5149
Mon 25 Feb 2019 5:54 pm By abdkode View Topic Features Review : Plugin MVDO untuk memuat naik video Youtube dan Clipmass
Features Review : Content Msocial untuk berkongsi kandungan artikel ke Facebook, Twitter, Google Plus dan Line
By abdkode Mon 25 Feb 2019 4:56 pm Board Bahasa Language
0
4482
Mon 25 Feb 2019 4:56 pm By abdkode View Topic Features Review : Content Msocial untuk berkongsi kandungan artikel ke Facebook, Twitter, Google Plus dan Line
Features Review : Module Mod slideshowck untuk membantu memaparkan imej dan video Youtube secara slaid
By abdkode Mon 25 Feb 2019 2:19 pm Board Bahasa Language
0
4641
Mon 25 Feb 2019 2:19 pm By abdkode View Topic Features Review : Module Mod slideshowck untuk membantu memaparkan imej dan video Youtube secara slaid