The problem here is that FormHelper does not load SessionHelper.

Sub-helpers do not merge automatically (unlike controllers), you have
to do it manually... like so

class AppHelper extends Helper {
  var $helpers = array('Session');

  function __construct() {
    if (is_subclass_of($this, 'AppHelper')) {
      $parentVars = get_class_vars('AppHelper');
      $this->helpers = array_merge($parenttVars['helpers'], $this-
>helpers);
    }
    parent::__construct();
  }
}

Please note: this is a very simplified example. It won't handle
plugins properly, or helpers with configuration arrays. But I'm sure
you get the gist.

hth
grigri

On Jul 20, 4:05 am, Galymzhan <[email protected]> wrote:
> Hi, group. I did a blog application in tutorial. I've 2 views like in
> tutorial:
> edit.ctp:
> <h1>Edit Post</h1>
> <?php
>         echo $form->create('Post', array('action' => 'edit'));
>         echo $form->input('title');
>         echo $form->input('body', array('rows' => '3'));
>         echo $form->input('id', array('type'=>'hidden'));
>         echo $form->end('Save Post');
> ?>
>
> and view.ctp:
> <h1><?php echo $post['Post']['title']?></h1>
> <p><small>Created: <?php echo $post['Post']['created']?></small></p>
> <p><?php echo $post['Post']['body']?></p>
>
> Now I want to override default functionality of url(). I've created
> app_helper.php in /app/ folder.
>
> class AppHelper extends Helper {
>   var $helpers = array('Session'); // I want to use Session helper
>   function url($url = NULL, $full = FALSE) {
>     if ($this->Session->check('lang')) {
>       // here is my custom logic
>     }
>   }
>
> }
>
> The problem is that when I'm trying to edit a post (edit.ctp), I get a
> fatal php error saying FormHelper::$session is undefined. I think that
> session helper isn't loaded.
> But when I view a post (view.ctp) everything works OK and my custom
> url() method works as expected. Help, please. I'm using CakePHP 1.3
> and php 5.2

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to