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
Features Review : Mod MDFile recent Module yang menunjukkan fail yang diupload
By abdkode Tue 12 Feb 2019 6:45 pm Board Bahasa Language
0
1210
Tue 12 Feb 2019 6:45 pm By abdkode
Features Review : Plugin MD Watermark memudahkan dalam meletakan tanda air atau watermark
By abdkode Tue 12 Feb 2019 4:20 pm Board Bahasa Language
0
658
Tue 12 Feb 2019 4:20 pm By abdkode
这个(Pace)是什么?
By Parichat Wed 06 Feb 2019 7:25 pm Board Chinese Language - 简体中文
0
607
Wed 06 Feb 2019 7:25 pm By Parichat
pace 가 뭐죠?
By Parichat Wed 06 Feb 2019 7:25 pm Board korean Language - 한국어
0
416
Wed 06 Feb 2019 7:25 pm By Parichat
Mindphp webboard 등록하는 방법
By wipaporn Wed 06 Feb 2019 6:12 pm Board korean Language - 한국어
0
74
Wed 06 Feb 2019 6:12 pm By wipaporn
minephp webboard 注册方法
By wipaporn Wed 06 Feb 2019 5:49 pm Board Chinese Language - 简体中文
0
122
Wed 06 Feb 2019 5:49 pm By wipaporn
How to register minephp webboard
By wipaporn Wed 06 Feb 2019 5:30 pm Board English Language
0
283
Wed 06 Feb 2019 5:30 pm By wipaporn
Let's get to know Korea
By wipaporn Mon 04 Feb 2019 8:04 pm Board korean Language - 한국어
0
477
Mon 04 Feb 2019 8:04 pm By wipaporn
Let's get to know China
By wipaporn Mon 04 Feb 2019 8:03 pm Board English Language
0
357
Mon 04 Feb 2019 8:03 pm By wipaporn
Apa itu Pace ? Masa yang diambil dalam 1 Kilometer atau 1 mile
By abdkode Mon 04 Feb 2019 7:31 pm Board Bahasa Language
0
652
Mon 04 Feb 2019 7:31 pm By abdkode
pace 가 뭐죠?
By wipaporn Mon 04 Feb 2019 7:12 pm Board korean Language - 한국어
2
2425
Tue 15 Oct 2019 1:17 pm By mindphp
Payment Gateway Thailand For Joomla extension On MooZiiCart
By mindphp Mon 04 Feb 2019 5:45 pm Board English Language
0
1231
Mon 04 Feb 2019 5:45 pm By mindphp