User Rating: 1 / 5

Star ActiveStar InactiveStar InactiveStar InactiveStar Inactive
 

later to see the changes.

- edit files in the folder hello.php Edit Controllers Add Method.

Com_helloworld/Controllers/hello.php

function edit()
 {

      JRequest:setVar('view', 'hello');
      parent::display();

 

- Modify the files in the folder hello.php Models.

com_helloworld/models/hello.php

public function getItem()
{
        $pk = JRequest::getVar('cid');
        if(is_array($pk)) {
                $pk = $pk[0]; 
        }
        if($pk == '') {
                return false; 
        }
        $db = JFactory::getDbo();     
        $query = $db->getQuery(true);
        $query->select('*')
                ->from('#__helloworld_hello')
                ->where($db->quoteName('id').'='.$db->quote($pk));
        $db->setQuery($query);
        $db->query();
        return $db->loadObject(); // ส่งค่าออกไปในรูปของ Object
}
protected function loadFormData()
{
        $data = $this->getItem();
        return $data;
}
function save($data) 
{
        $db = JFactory::getDbo();
        $obj = (object) $data;
        try {
                if($obj->id) { 
                        $db->updateObject('#__helloworld_hello', $obj, 'id');
                } else {
                        $db->insertObject('#__helloworld_hello', $obj, 'id');
                }

        } catch (RuntimeException $exc) {                
                $this->setError($exc->getMessage());
                return false;
        }
        return true;
}

 

- Modify the files in the folder hello.xml models / forms to id is hidden.

com_helloworld/models/forms/hello.xml

<?xml version="1.0" encoding="utf-8"?>
<form>
        <fieldset name="hello_form">
                <field 
                        name="id"
                        type="hidden"
                />            
                <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>

 

 

Chapter 13 - Delete Data Component Development

Recent Topics
Subject
Post Reply
Open
Recent
Plugin Content MChangelog ,helps add content that has changed, update, and fix the problem
By prmindphp Thu 12 Dec 2019 6:46 pm Board English Language
0
703
Thu 12 Dec 2019 6:46 pm By prmindphp
Pace Calculator
By prmindphp Wed 11 Dec 2019 6:53 pm Board English Language
0
669
Wed 11 Dec 2019 6:53 pm By prmindphp
Introducing to MooZiiCart's Coupons feature, create coupons on website sell products online it is certain to boost sales
By prmindphp Mon 09 Dec 2019 11:06 am Board English Language
0
643
Mon 09 Dec 2019 11:06 am By prmindphp
Introducing to MooZii Opencart - Template MooZiicart create a beautiful website by yourself
By prmindphp Fri 06 Dec 2019 10:47 am Board English Language
0
631
Fri 06 Dec 2019 10:47 am By prmindphp
Introducing the new Mindphp.com Webboard system function (phpbb v.3.2)
By mindphp Wed 04 Dec 2019 8:45 pm Board English Language
0
566
Wed 04 Dec 2019 8:45 pm By mindphp
Module "Login" of MooZiicart easy to use, just install
By prmindphp Tue 03 Dec 2019 1:32 pm Board English Language
0
152
Tue 03 Dec 2019 1:32 pm By prmindphp
Module "MooZiiCart Search" of MooZiicart for search keywords of what we want
By prmindphp Mon 02 Dec 2019 11:31 am Board English Language
0
146
Mon 02 Dec 2019 11:31 am By prmindphp
Features Component MooZiiCart in Joomla for create website to sell products online
By prmindphp Sat 30 Nov 2019 7:00 pm Board English Language
1
1770
Thu 05 Mar 2020 5:27 pm By prmindphp
Business Analyst Training
By NehaaB Fri 29 Nov 2019 5:27 pm Board English Language
0
85
Fri 29 Nov 2019 5:27 pm By NehaaB
Program convert area
By prmindphp Wed 27 Nov 2019 11:26 am Board English Language
0
85
Wed 27 Nov 2019 11:26 am By prmindphp
Program exchange rate - Information form Bank of Thailand API
By prmindphp Tue 26 Nov 2019 2:34 pm Board English Language
0
84
Tue 26 Nov 2019 2:34 pm By prmindphp
Tracking Thailand Post Program
By prmindphp Mon 25 Nov 2019 5:47 pm Board English Language
0
120
Mon 25 Nov 2019 5:47 pm By prmindphp
Square Root Calculate Program
By prmindphp Fri 22 Nov 2019 11:30 am Board English Language
0
141
Fri 22 Nov 2019 11:30 am By prmindphp
The program calculates the mean, the variable, the standard deviation
By prmindphp Fri 22 Nov 2019 11:12 am Board English Language
0
120
Fri 22 Nov 2019 11:12 am By prmindphp
Introducing the new Mindphp.com Webboard system function (phpbb v.3.2)
By numtan5839 Tue 19 Nov 2019 6:06 pm Board English Language
0
118
Tue 19 Nov 2019 6:06 pm By numtan5839
The most popular currency pairs in the Forex for new traders
By numtan5839 Mon 18 Nov 2019 5:32 pm Board English Language
0
118
Mon 18 Nov 2019 5:32 pm By numtan5839
BIG DATA and Hadoop
By Inglejyoti Mon 18 Nov 2019 4:03 pm Board English Language
0
201
Mon 18 Nov 2019 4:03 pm By Inglejyoti
The most popular currency in the Forex
By numtan5839 Mon 18 Nov 2019 3:24 pm Board English Language
0
104
Mon 18 Nov 2019 3:24 pm By numtan5839
How to use the SQRT function in Excel
By numtan5839 Mon 18 Nov 2019 2:46 pm Board English Language
0
146
Mon 18 Nov 2019 2:46 pm By numtan5839
Deposit money into account with Thailand Post by Bank@post service
By numtan5839 Mon 18 Nov 2019 11:42 am Board English Language
0
157
Mon 18 Nov 2019 11:42 am By numtan5839