Jump to content


Photo

Extending Modules Functions

metadata extend accounts module

  • Please log in to reply
No replies to this topic

#1 jamesGO3D

jamesGO3D

    Advanced Member

  • Members
  • PipPipPip
  • 47 posts

Posted 14 February 2014 - 06:46 PM

I know i asked this at the developers meeting on Tuesday but I am still having trouble defining classes and class functions in an external file. I created a file within accounts/models/ called AccountExtend.php and loaded it thought the AccountsModule.php on line 53 like this:

public function getRootModelNames()
{
return array('Account, AccountExtend');
}

Within the AccountExtend.php file I have this function which is changing the label from the default "Billing Address" to say "Property Address"

class AccountExtend extends Account implements StarredInterface
{
     protected static function translatedAttributeLabels($language)
{
$params = LabelUtil::getTranslationParamsForAllModules();
$paramsForAffiliations = $params;

return array_merge(OwnedSecurableItem::translatedAttributeLabels($language),
array(

'billingAddress' => Zurmo::t('AccountsModule', 'Property Address', array(), null, $language),

)
);

} 

So above I merge this array with the class "OwnedSecurableItem" formerly being merged in the extended Account.php and replaced "OwnedSecurableItem" with "AccountExtend" within the Account.php model and did a "merge_diff" php function to overwrite the default label.

 

Now my question is this, Is this the best way to do this? any tips or advice? My next struggle is trying to extend a function within the Account.php module to say add a custom relational drop down field or to add any other functionality. How can I go about this since these are more complex arrays that contain elements?







Also tagged with one or more of these keywords: metadata, extend, accounts, module

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users