Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7507999
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T22:35:56+00:00 2026-05-29T22:35:56+00:00

Improving on this question: Is it good practice to add own file in lib/Varien/Data/Form/Element

  • 0

Improving on this question:
Is it good practice to add own file in lib/Varien/Data/Form/Element folder

The accepted answer shows how to extend a Varien form element, but this will not work if you want to package it into a custom module.

What would be the proper method of extending the Varien form element in a module? A simple XML setting I’m hoping?

Update:

Thanks Vinai for the response. Although that does work, I was hoping to extend the form element somehow. My extension is using the base File form element to allow administrators to upload files to categories. So, I’m not directly adding the form elements to the fieldset myself.

I suppose it’s possible to to check for the file input on my category block on the backend: Mage_Adminhtml_Block_Catalog_Category_Tab_Attributes , and then change the form element if it is ‘file’ to ‘mycompany_file’ — but this seems like a workaround.

Is there an easier way? Thanks again Vinai.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T22:35:56+00:00Added an answer on May 29, 2026 at 10:35 pm

    On the Varien_Data_Form instance you can specify custom element types like this:

    $fieldset->addType('custom', 'Your_Module_Model_Form_Element_Custom');
    

    Then, add your element with

    $fieldset->addField('the_name', 'custom', $optionsArray);
    

    If you are using a form without fieldsets you can do the same on the Varien_Data_Forminstance, too.

    EDIT: Expand answer because of new additional details in the question.

    In the class Mage_Adminhtml_Block_Widget_Form::_setFieldset() there is the following code:

    $rendererClass  = $attribute->getFrontend()->getInputRendererClass();
    if (!empty($rendererClass)) {
        $fieldType  = $inputType . '_' . $attribute->getAttributeCode();
        $fieldset->addType($fieldType, $rendererClass);
    }
    

    Because of this the attribute frontend_input_renderer on the attributes can be used to specify custom element classes.
    This property can be found in the table catalog_eav_attribute, and luckily enough it isn’t set for any of the category image attributes.

    Given this, there are several ways to apply customizaton.

    One option is to simply set the element class in the table using an upgrade script.
    Another would be using an observer for the eav_entity_attribute_load_after event and setting the input renderer on the fly if the entity_type_id and the input type matches.

    So it is a little more involved then just regular class rewrites in Magento, but it is quite possible.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've seen this question regading the importing of js-files related to the tag content
Could anyone find a way of improving this code a bit? I want to
G'day, OK, I have now rewritten this question totally: I am trying to import
This isn't actually a homework question per se, just a question that keeps nagging
I have been searching desperately for an answer to this question, but not found
This question was originally asking 'What KPIs do you use to in a software
I recently asked this question about how to simulate type classes in D and
I was trying to solve this Project Euler Question . I implemented the sieve
My situation is similar to one in this question... The difference is, In our
This is a follow-up to this previous question: Complicated COUNT query in MySQL .

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.