0

I have following structure

<?xml version="1.0"?>
<config>
<modules>
    <Namespace_News>
        <version>0.1.0</version>
    </Namespace_News>
</modules>
<frontend>
    <routers>
        <news>
            <use>standard</use>
            <args>
                <module>Namespace_News</module>
                <frontName>news</frontName>
            </args>
        </news>
    </routers>
    <layout>
        <updates>
            <news>
                <file>news.xml</file>
            </news>
        </updates>
    </layout>
</frontend>
<admin>
    <routers>
        <news>
            <use>admin</use>
            <args>
                <module>Namespace_News</module>
                <frontName>news</frontName>
            </args>
        </news>
        <adminhtml>
            <args>
                <modules>
                    <namespace_news before="Mage_Adminhtml">Namespace_News</namespace_news>
                </modules>
            </args>
        </adminhtml>
    </routers>
</admin>
<adminhtml>
    <menu>
        <news module="news">
            <title>News</title>
            <sort_order>71</sort_order>
            <children>
                <items module="news">
                    <title>Manage Items</title>
                    <sort_order>0</sort_order>
                    <action>news/adminhtml_news</action>
                </items>
                <account module="news">
                    <title>My Account</title>
                    <sort_order>1</sort_order>
                    <action>news/system_account</action>
                </account>
            </children>
        </news>
    </menu>
    <acl>
        <resources>
            <all>
                <title>Allow Everything</title>
            </all>
            <admin>
                <children>
                    <Namespace_News>
                        <title>News Module</title>
                        <sort_order>10</sort_order>
                    </Namespace_News>
                    <Namespace_Account>
                        <title>My Account</title>
                        <sort_order>1</sort_order>
                    </Namespace_Account>
                </children>
            </admin>
        </resources>
    </acl>
    <layout>
        <updates>
            <news>
                <file>news.xml</file>
            </news>
        </updates>
    </layout>
</adminhtml>   
<global>
    <models>
        <news>
            <class>Namespace_News_Model</class>
            <resourceModel>news_mysql4</resourceModel>
        </news>
        <news_mysql4>
            <class>Namespace_News_Model_Mysql4</class>
            <entities>
                <news>
                    <table>news</table>
                </news>
            </entities>
        </news_mysql4>
    </models>
    <resources>
        <news_setup>
            <setup>
                <module>Namespace_News</module>
            </setup>
            <connection>
                <use>core_setup</use>
            </connection>
        </news_setup>
        <news_write>
            <connection>
                <use>core_write</use>
            </connection>
        </news_write>
        <news_read>
            <connection>
                <use>core_read</use>
            </connection>
        </news_read>
    </resources>
    <blocks>
        <news>
            <class>Namespace_News_Block</class>
        </news>
        <adminhtml>
             <rewrite>
        <system_account_edit>Namespace_News_Block_Account_Edit</system_account_edit>
<system_account_edit_form>Namespace_News_Block_Account_Edit_Form</system_account_edit_form>
            </rewrite>
        </adminhtml>
    </blocks>
    <helpers>
        <news>
            <class>Namespace_News_Helper</class>
        </news>
    </helpers>
</global>

I have Form.php at directory
app/code/local/Namespace/News/Block/Account/Edit/Form.php

<?php
//require_once "Mage/Adminhtml/Block/System/Account/Edit/Form.php";
class Namespace_News_Block_Account_Edit_Form extends Mage_Adminhtml_Block_System_Account_Edit_Form
{
    protected function _prepareForm()
    {
        $userId = Mage::getSingleton('admin/session')->getUser()->getId();
        $user = Mage::getModel('admin/user')->load($userId);
        $user->unsetData('password');
        $form = new Varien_Data_Form();
        $fieldset = $form->addFieldset('base_fieldset', array('legend'=>Mage::helper('adminhtml')->__('Account Information')));
        $fieldset->addField('username', 'text', array(
                'name'  => 'username',
                'label' => Mage::helper('adminhtml')->__('User Name1'),
                'title' => Mage::helper('adminhtml')->__('User Name'),
                'required' => true,
            )
        );
        $fieldset->addField('firstname', 'text', array(
                'name'  => 'firstname',
                'label' => Mage::helper('adminhtml')->__('First Name1'),
                'title' => Mage::helper('adminhtml')->__('First Name'),
                'required' => true,
            )
        );
        $fieldset->addField('lastname', 'text', array(
                'name'  => 'lastname',
                'label' => Mage::helper('adminhtml')->__('Last Name'),
                'title' => Mage::helper('adminhtml')->__('Last Name'),
                'required' => true,
            )
        );
        $fieldset->addField('user_id', 'hidden', array(
                'name'  => 'user_id',
            )
        );
        $fieldset->addField('email', 'text', array(
                'name'  => 'email',
                'label' => Mage::helper('adminhtml')->__('Email'),
                'title' => Mage::helper('adminhtml')->__('User Email'),
                'required' => true,
            )
        );
        $fieldset->addField('password', 'password', array(
                'name'  => 'new_password',
                'label' => Mage::helper('adminhtml')->__('New Password'),
                'title' => Mage::helper('adminhtml')->__('New Password'),
                'class' => 'input-text validate-admin-password',
            )
        );
        $fieldset->addField('confirmation', 'password', array(
                'name'  => 'password_confirmation',
                'label' => Mage::helper('adminhtml')->__('Password Confirmation'),
                'class' => 'input-text validate-cpassword',
            )
        );
        $form->setValues($user->getData());
        $form->setAction($this->getUrl('*/system_account/save'));
        $form->setMethod('post');
        $form->setUseContainer(true);
        $form->setId('edit_form');
        $this->setForm($form);
        return parent::_prepareForm();
    }
}

I am trying to override block Form.php but it doesn't work. Thanks in advance.

1
  • Replace all Occurance of NameSpace with the Xoptimo and follow my answer. Jul 10, 2014 at 11:22

1 Answer 1

1
<blocks>
    <news>
        <class>Xoptimo_News_Block</class>
    </news>
    <adminhtml>
        <rewrite>
            <system_account_edit_form>Xoptimo_News_Block_Account_Edit_Form</system_account_edit_form>
        </rewrite>
    </adminhtml>
</blocks>

and Please Check your all Namespace should replace with the Xoptimo

8
  • Thanks for your precious reply. I have tried it now. But still my block doesn't override. Any other suggestion plz.
    – YKJ
    Jul 10, 2014 at 11:47
  • please paste your updated code here again Jul 10, 2014 at 11:49
  • I have updated answer. Block "Namespace_News_Block_Account_Edit" override successfully. But it rises issue in "Namespace_News_Block_Account_Edit_Form" block.
    – YKJ
    Jul 10, 2014 at 12:08
  • please paste updated xml also i can check and let you know.the current xml is not updated i think Jul 10, 2014 at 12:16
  • I have update Xml for condition added system_ in block section. And Change of Namespace is added to Form.php
    – YKJ
    Jul 10, 2014 at 12:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.