benturkia / zendframeworkstorefront

Automatically exported from code.google.com/p/zendframeworkstorefront
0 stars 0 forks source link

Injection of the model object into forms in SF/Model/Abstract.php #8

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Concerning Chapter 7
1) The injection of the model into forms in the file 
/.../storefront/library/SF/Model/Abstract.php with the code:
 $this->_forms[$name] = new $class(array('model' => $this));
results, when displaying the form Register/user, in the following warning.

Warning: htmlspecialchars() expects parameter 1 to be string, object given in
  ...\ZendFramework-1.11.4\library\Zend\View\Abstract.php on line 897

  The model is only used in the Table form and this warning does not appear when it is displayed.

I therefore got around this problem by using the conditional code:

if($name == 'cartTable'){   
        $this->_forms[$name] = new $class(array('model' => $this));
       }
        else{
             $this->_forms[$name] = new $class('');
            }
            return $this->_forms[$name];

The question is why is there this apparent anomaly ?

2) A basic simple question
    I've been looking for the definition and use of the last two parameters  in the anchor
i'e. "default" and "true".  
Where is it and how are they used?

    $this->view->url(array(
            'controller' => 'cart', 
            'action' => 'view',
            'module' => 'storefront'
            ),
            'default',
            true

Again, following my last posts, I have still not solved the AutoLoad problem 
and have had to include the relevant files to make the code for the cart 
accessible

Original issue reported on code.google.com by ma...@michaelafox.org on 14 Aug 2011 at 4:53

GoogleCodeExporter commented 8 years ago
With respect to the Table form, which requires access to the model, I note that 
it extends from SF_Form_Abstract, which provides setter and getter methods for 
the model. The register/edit forms do not inherit these methods. Is this the 
reason for the warning? If so then my conditional code seems to be required. 

Original comment by ma...@michaelafox.org on 14 Aug 2011 at 7:10

GoogleCodeExporter commented 8 years ago
I had the same problem and fixed it by making Base.php extend SF_Form_Abstract..

In application/module/storefront/forms/user/Base.php  do the following 

SF_Form_Abstract  class Storefront_Form_User_Base extends SF_Form_Abstract

I guess the Author forget to mention this

Original comment by amanue...@gmail.com on 13 Sep 2011 at 3:32