Simple joomla component Helloworld

Moderator: mindphp

iig75
PHP Jr. Member
PHP Jr. Member
โพสต์: 11
ลงทะเบียนเมื่อ: 26/09/2021 7:40 pm

Simple joomla component Helloworld

โพสต์ที่ยังไม่ได้อ่าน โดย iig75 »

Hi everybody,

I try to create simple joomla component helloworld. I follow instructions in this tutorial:
https://www.mindphp.com/en/online-tutor ... pment.html
I save data into db, read and list data from db, but when I try to edit data I can't load data from db to the form, the form is show but blank.
:arrow: I accept any proposal
com_helloworld_5.zip
(7.68 KiB) ดาวน์โหลดแล้ว 93 ครั้ง
.
ภาพประจำตัวสมาชิก
mindphp
ผู้ดูแลระบบ MindPHP
ผู้ดูแลระบบ MindPHP
โพสต์: 41127
ลงทะเบียนเมื่อ: 22/09/2008 6:18 pm
ติดต่อ:

Re: Simple joomla component Helloworld

โพสต์ที่ยังไม่ได้อ่าน โดย mindphp »

pls. show your error.
(Set your joomla Error Reporting => Development )
ติดตาม VDO: http://www.youtube.com/c/MindphpVideoman
ติดตาม FB: https://www.facebook.com/pages/MindphpC ... 9517401606
หมวดแชร์ความรู้: https://www.mindphp.com/forums/viewforum.php?f=29
รับอบรม และพัฒนาระบบ: https://www.mindphp.com/forums/viewtopic.php?f=6&t=2042
iig75
PHP Jr. Member
PHP Jr. Member
โพสต์: 11
ลงทะเบียนเมื่อ: 26/09/2021 7:40 pm

Re: Simple joomla component Helloworld

โพสต์ที่ยังไม่ได้อ่าน โดย iig75 »

First, Thanks for your replay!
I set error level to development, but there is no any errors!
When I press button [edit], form is loading but there no information inside, just empty form, like I press [new] button.
Button [new] works OK. New data was saved in db. But edit is not working...
I think, I miss something small and stupid again.
iig75
PHP Jr. Member
PHP Jr. Member
โพสต์: 11
ลงทะเบียนเมื่อ: 26/09/2021 7:40 pm

Re: Simple joomla component Helloworld

โพสต์ที่ยังไม่ได้อ่าน โดย iig75 »

SOLVED!!!
I checked all files line by line, in model->hello.php in function getForm
i had writed 'loadData' => $loadData
i need to write 'load_data' => $loadData
and now everything is working perfectly!
Special thanks to mindphp for all tutorials and help!
iig75
PHP Jr. Member
PHP Jr. Member
โพสต์: 11
ลงทะเบียนเมื่อ: 26/09/2021 7:40 pm

Re: Simple joomla component Helloworld

โพสต์ที่ยังไม่ได้อ่าน โดย iig75 »

Another problem. Function delete doesn't works!

When I try to delete record, press button [delete], I receive
a message "Invalid token!".

The first line of function delete() in controllers->hello.php is JRequest::checkToken() or die('Invalid token!');
I understand that the checkToken is fail and execute second part "die".

If I comment first line of delete() /not check for token/,
it's works, the record has been deleted, but I beleve it's not best idea .

I have the same line /checkToken/ in function Save() in the same file, but save is working perfectly, the checkToken is success.
For pity function delete() doesn't works, and I really don't know where is the problem.

Joomla error level is set to development -> no errors, no warnings and no notices.
Line by line reading was not successfully this time...

In views->hello->default.php and views->hellos->default.php at the end
of the two files, there is <?php echo JHtml::_('form.token');?>

Can somebody let me an idea how to find the problem?
com_helloworld_6.zip
(7.81 KiB) ดาวน์โหลดแล้ว 97 ครั้ง
P.S. If I change first line from
JRequest::checkToken() or die('Invalid token!');
to
$this->checkToken() or die('Invalid token!');

I receive:
Warning
The security token did not match. The request was aborted to prevent any security breach. Please try again.
ภาพประจำตัวสมาชิก
mindphp
ผู้ดูแลระบบ MindPHP
ผู้ดูแลระบบ MindPHP
โพสต์: 41127
ลงทะเบียนเมื่อ: 22/09/2008 6:18 pm
ติดต่อ:

Re: Simple joomla component Helloworld

โพสต์ที่ยังไม่ได้อ่าน โดย mindphp »

check your Token must have define on your input form. (tree view or form view)

view source tree view page must show like this

....
<input type="hidden" name="task" value="" />
<input type="hidden" name="boxchecked" value="0" />
<input type="hidden" name="3f426740818e081ad77d0e2f78c811ed" value="1" /> </div>
</form>
ติดตาม VDO: http://www.youtube.com/c/MindphpVideoman
ติดตาม FB: https://www.facebook.com/pages/MindphpC ... 9517401606
หมวดแชร์ความรู้: https://www.mindphp.com/forums/viewforum.php?f=29
รับอบรม และพัฒนาระบบ: https://www.mindphp.com/forums/viewtopic.php?f=6&t=2042
iig75
PHP Jr. Member
PHP Jr. Member
โพสต์: 11
ลงทะเบียนเมื่อ: 26/09/2021 7:40 pm

Re: Simple joomla component Helloworld

โพสต์ที่ยังไม่ได้อ่าน โดย iig75 »

Yes, in view source in browser I have the same source as yours:

<input type="hidden" name="task" value="">
<input type="hidden" name="boxchecked" value="0">
<input type="hidden" name="c" value="hello">
<input type="hidden" name="filter_order" value="id">
<input type="hidden" name="fiter_order_Dir" value="asc"

<input type="hidden" name="30e884863d0edb8f8fa6b560b325764d" value="1" />

But "Invalid token!" message doesn't disappear...
iig75
PHP Jr. Member
PHP Jr. Member
โพสต์: 11
ลงทะเบียนเมื่อ: 26/09/2021 7:40 pm

Re: Simple joomla component Helloworld

โพสต์ที่ยังไม่ได้อ่าน โดย iig75 »

SOLVED!!!

You are my Best Friend! :-)
When I posted the source from my browser, I sow that I missed a single ">" for last <input before token.
It was very very mysterious error... I spent so many time for a single ">"...
Thank you very much again for your help!

Message
Delete successfully!
ภาพประจำตัวสมาชิก
mindphp
ผู้ดูแลระบบ MindPHP
ผู้ดูแลระบบ MindPHP
โพสต์: 41127
ลงทะเบียนเมื่อ: 22/09/2008 6:18 pm
ติดต่อ:

Re: Simple joomla component Helloworld

โพสต์ที่ยังไม่ได้อ่าน โดย mindphp »

My pleasure.

I don't like this line :lol: :lol: :lol:

โค้ด: เลือกทั้งหมด

<input type="hidden" name="fiter_order_Dir" value="asc"
Haha.
ติดตาม VDO: http://www.youtube.com/c/MindphpVideoman
ติดตาม FB: https://www.facebook.com/pages/MindphpC ... 9517401606
หมวดแชร์ความรู้: https://www.mindphp.com/forums/viewforum.php?f=29
รับอบรม และพัฒนาระบบ: https://www.mindphp.com/forums/viewtopic.php?f=6&t=2042
บุคคลทั่วไป

Re: Simple joomla component Helloworld

โพสต์ที่ยังไม่ได้อ่าน โดย บุคคลทั่วไป »

iig75 เขียน: 01/11/2021 7:15 pm SOLVED!!!

You are my Best Friend! :-)
When I posted the source from my browser, I sow that I missed a single ">" for last <input before token.
It was very very mysterious error... I spent so many time for a single ">"...
Thank you very much again for your help!

Message
Delete successfully!
mindphp เขียน: 01/11/2021 6:30 pm check your Token must have define on your input form. (tree view or form view)

view source tree view page must show like this

....
<input type="hidden" name="task" value="" />
<input type="hidden" name="boxchecked" value="0" />
<input type="hidden" name="3f426740818e081ad77d0e2f78c811ed" value="1" /> </div>
</form>
ตอบกลับโพส

ผู้ใช้งานขณะนี้

สมาชิกกำลังดูบอร์ดนี้: ไม่มีสมาชิกใหม่ และบุคลทั่วไป 21