Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

[resolved] How do I use helper in views? 
 
primerg
Jr. Member
 
Total Posts:  7
Joined:  2008-07-02
 

I have created my .phtml for a local extension and it displays just fine. My problem is that I am unable to use helper functions inside my view. Below is my code for my view files

file: design/templates/default/default2/customer2/form/getclear.phtml

<h4 class="legend"><?php echo $this->__('Personal Information'?></h4>
        <
ul>
            <
li>
                <
div class="input-box">
                    <
label for="email_address"><?php echo $this->__('Email Address'?> <span class="required">*</span></label><br/>
                    <
input type="text" name="email" id="email_address" value="<?php echo $this->htmlEscape($this->getFormData()->getEmail()) ?>" title="<?php echo $this->__('Email Address') ?>" class="validate-email required-entry input-text" />
                </
div>
            </
li>
            
<?php if ($this->isNewsletterEnabled()): ?>
            
<li>
                <
input type="checkbox" name="is_subscribed" title="<?php echo $this->__('Sign Up for Newsletter') ?>" value="1" id="is_subscribed" <?php if($this->getFormData()->getIsSubscribed()): ?> checked="checked"<?php endif ?> />
                <
label for="is_subscribed"><?php echo $this->__('Sign Up for Newsletter'?></label>
            </
li>
            
<?php endif ?>
        
</ul>

I get this error:
Fatal error: Call to a member function getEmail() on a non-object ...

My folder structure is like this

Customer2 //
    
Block
      Form
         Getclear
.php
    controllers
         AccountController
.php
    etc
         config
.xml
    Helper
         Data
.php

My accountcontroller

class Customer2_AccountController extends Mage_Core_Controller_Front_Action
{
    
/**
     * Retrieve customer session model object
     *
     * @return Mage_Customer_Model_Session
     */
    
protected function _getSession()
    
{
        
return Mage::getSingleton('customer/session');
    
}

    
/**
     * Customer register form page
     */
    
public function getclearAction()
    
{
        
/*if ($this->_getSession()->isLoggedIn()) {
            $this->_redirect('* /*');
            return;
        }*/
        
        
$this->loadLayout();
        
$this->_initLayoutMessages('customer/session');
        
$this->renderLayout();
    
}
}

How can I use functions in Block/Form/Getclear.php?

 
Magento Community Magento Community
Magento Community
Magento Community
 
primerg
Jr. Member
 
Total Posts:  7
Joined:  2008-07-02
 

I figured it out. it was a setting error in config.xml

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top