Tuesday, December 16, 2014

Re: 3.0 using FormHelper inside MyHtmlHelper

See that one?
https://github.com/cakephp/cakephp/blob/3.0/src/View/Helper/HtmlHelper.php#L39

It's dangerous to overwrite a core helper and remove functionality from it.

So you should either not overwrite $helpers, or do it correcty. Meaning, appending to it while not removing anything:

    public $helpers = ['Url', 'Form']; 


mark


Am Sonntag, 14. Dezember 2014 05:32:59 UTC+1 schrieb Ahmad baiquni habibi:
hi, I try to do http://book.cakephp.org/3.0/en/views/helpers.html#including-other-helpers into MyHtmlHelper, but get error. Please help how to do it properly?

here my code:
<?php
namespace App\View\Helper;
use Cake\View\Helper\HtmlHelper;

class MyHtmlHelper extends HtmlHelper {
    
   
    public $helpers = ['Form'];
    /*
    Fatal Error
    Error: Call to a member function build() on a non-object
    File E:\xampp\htdocs\portfolio\hrd\vendor\cakephp\cakephp\src\View\Helper\HtmlHelper.php
    Line: 323
    */
       
    public function edit($id = null){
   
        $title = 'edit';
        $url = ['action'=>'edit', $id];
        return $this->link($title, $url, $options = array());
   
    }
   
    public function hapus($id = null){
        $title = 'hapus';
        $url = ['action'=>'delete', $id];
        $options['confirm'] = 'yakin menghapus?';
       
        return $this->Form->postLink($title, $url , $options);
   
    }   
   
}



--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

No comments: