I need to append a input field to the admin log in page. I have created an Observer.php hoping to do so. I simply want to add an input to the login form on the admin side.
app\code\local\Wsu\NewtworkSecurities\Model\Observer.php
class Wsu_NewtworkSecurities_Model_Observer extends Mage_Admin_Model_Observer {
public function appendfeild() {
echo $this->getLayout()->createBlock('wsu_newtworksecurities/newtworksecurities.feildblock')->toHtml();
}
}
app\code\local\Wsu\NewtworkSecurities\etc\config.xml
<?xml version="1.0" encoding="utf-8"?>
<config>
<modules>
<Wsu_NewtworkSecurities>
<version>0.1.0</version>
</Wsu_NewtworkSecurities>
</modules>
<global>
<events>
<controller_action_predispatch_adminhtml_index_index>
<observers>
<newtworksecurities>
<class>newtworksecurities/observer</class>
<method>appendfeild</method>
</newtworksecurities>
</observers>
</controller_action_predispatch_adminhtml_index_index>
</events>
</global>
</config>
app\design\adminhtml\default\default\layout\wsu\newtworksecurities.xml
<?xml version="1.0"?>
<layout version="0.1.0">
<feildblock>
<reference name="head">
<action method="addJs">
<script>wsu/newtworksecurities/newtworksecurities.js</script>
</action>
</reference>
</feildblock>
<default>
<adminhtml_index_login>
<update handle="feildblock" />
<reference name="form.additional.info">
<block type="wsu_newtworksecurities/wsu_newtworksecurities" name="wsu_newtworksecurities">
<action method="setFormId"><formId>backend_login</formId></action>
<action method="setImgWidth"><width>226</width></action>
<action method="setImgHeight"><width>50</width></action>
</block>
<block type="wsu_newtworksecurities/feildblock" name="newtworksecurities.feildblock"
template="wsu/newtworksecurities/feildblock.phtml" />
</reference>
</adminhtml_index_login>
</default>
</layout>
app\design\adminhtml\default\default\template\wsu\newtworksecurities\feildblock.phtml
<input id="url" type="text" name="<?php echo $this->getfeildblock() ?>" />
EDIT
So the answer is that it should be the full package_extension class name in the config events node value. this was the fix, adding the wsu_
to the class value. Although @Vicky hit on another try I did, it was not full solution to appending to the login page. This is what I ended up as
<controller_action_predispatch_adminhtml_index_login>
<observers>
<newtworksecurities>
<class>wsu_newtworksecurities/observer</class>
<method>appendfeild</method>
</newtworksecurities>
</observers>
</controller_action_predispatch_adminhtml_index_login>
EDIT 2
Now although it I was able to get to the method I have not been able to get the html from the phtml to show up in the <?php echo $this->getChildHtml('form.additional.info'); ?>
. I am expecting that app\design\adminhtml\default\default\template\wsu\newtworksecurities\feildblock.phtml
was going to show up but as of yet nothing. I have read that I may be seeing that that block is being over write it's self, I have tried to change the events I'm observing with out change. I'm sure it's hitting my method as I added echo "TEST!!!!";
and I see it right at the top as expected. I don't see that block getting the template.
EDIT 3
It is worth noting that it works for the front end if I just do this, no config event, and use the layout update. So this is what works on the front.
app\design\frontend\base\default\layout\newtworksecurities.xml
<?xml version="1.0"?>
<layout>
<feildset>
<reference name="head">
<action method="addJs">
<script>wsu/newtworksecurities/newtworksecurities.js</script>
</action>
</reference>
</feildset>
<customer_account_create>
<update handle="feildset" />
<reference name="form.additional.info">
<block type="wsu_newtworksecurities/feildset" name="newtworksecurities.feildset"
template="wsu/newtworksecurities/feildset.phtml" />
</reference>
</customer_account_create>
<review_product_list>
<update handle="feildset" />
<reference name="product.review.form.fields.before">
<block type="wsu_newtworksecurities/feildset" name="newtworksecurities.feildset"
template="wsu/newtworksecurities/feildset.phtml" />
</reference>
</review_product_list>
<wsu_newtworksecurities_error_index>
<reference name="content">
<block type="core/template" name="newtworksecurities.error" template="wsu/newtworksecurities/error.phtml"/>
</reference>
</wsu_newtworksecurities_error_index>
</layout>
app\code\local\Wsu\NewtworkSecurities\etc\config.xml
<?xml version="1.0" encoding="utf-8"?>
<config>
<modules>
<Wsu_NewtworkSecurities>
<version>0.1.0</version>
</Wsu_NewtworkSecurities>
</modules>
<frontend>
<layout>
<updates>
<wsu_newtworksecurities>
<file>newtworksecurities.xml</file>
</wsu_newtworksecurities>
</updates>
</layout>
</frontend>
</config>
SO this works but I can't get it do work on the login page. I have added
<admin>
<layout>
<updates>
<wsu_newtworksecurities>
<file>newtworksecurities.xml</file>
</wsu_newtworksecurities>
</updates>
</layout>
</admin>
to the config file and in
app\design\adminhtml\default\default\layout\wsu\newtworksecurities.xml
<?xml version="1.0"?>
<layout version="0.1.0">
<feildset>
<reference name="head">
<action method="addJs">
<script>wsu/newtworksecurities/newtworksecurities.js</script>
</action>
</reference>
</feildset>
<adminhtml_index_login>
<update handle="feildset" />
<reference name="form.additional.info">
<block type="wsu_newtworksecurities/feildset" name="newtworksecurities.feildset"
template="wsu/newtworksecurities/feildset.phtml" />
</reference>
</adminhtml_index_login>
<wsu_newtworksecurities_error_index>
<reference name="content">
<block type="core/template" name="newtworksecurities.error" template="wsu/newtworksecurities/error.phtml"/>
</reference>
</wsu_newtworksecurities_error_index>
</layout>