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

How to format a user defined customer attribute with a dropdown in adminhtml (similar to “is confirmed") [SOLVED]
 
Vinai
Sr. Member
 
Avatar
Total Posts:  218
Joined:  2008-04-04
Heidelberg, Germany
 

Hello,
I now have successfully added a customer attribute (yay!).
In the Adminhtml backend under Account Information it is editable as a text input field.
I would like to have a dropdown instead, similar to the “is confirmed” attribute.
I can’t find the difference between my attribute and confirmed. same input type in the eav_attribute table, no diffenet model in the db either.
Can someone give me a pointer how to do that?

Thanks in advance, help is much appreciated.

Vinai

 
Magento Community Magento Community
Magento Community
Magento Community
 
Vinai
Sr. Member
 
Avatar
Total Posts:  218
Joined:  2008-04-04
Heidelberg, Germany
 

*bump*
Still looking for a way to do that.

Thanks,
Vinai

 
Magento Community Magento Community
Magento Community
Magento Community
 
LeeSaferite
Guru
 
Avatar
Total Posts:  322
Joined:  2007-08-31
Lake City, FL
 

One trick is to look at the ‘source_model’ column of the attribute in the ‘eav_attribute’ table.  This corresponds to a Model class.

This show how the Tax Class attribute dropdown is populated

SELECT FROM magento.eav_attribute where attribute_code 'tax_class_id'

It uses this model class: Mage_Tax_Model_Class_Source_Product

Try looking at that and see if it helps

 
Magento Community Magento Community
Magento Community
Magento Community
 
Vinai
Sr. Member
 
Avatar
Total Posts:  218
Joined:  2008-04-04
Heidelberg, Germany
 

Thanks again Lee!

I will look into that

Vinai

 
Magento Community Magento Community
Magento Community
Magento Community
 
Vinai
Sr. Member
 
Avatar
Total Posts:  218
Joined:  2008-04-04
Heidelberg, Germany
 

I decided to override Mage_Adminhtml_Block_Customer_Edit_Tab_Account to do the job like Varien did with the confirmed customer attribute.
But I still had a good look at how the tax class works, thanks for the pointer.

Marking this as solved,

Vinai

 
Magento Community Magento Community
Magento Community
Magento Community
 
LeeSaferite
Guru
 
Avatar
Total Posts:  322
Joined:  2007-08-31
Lake City, FL
 

You know, you could just set the ‘frontend_input’, ‘frontend_label’, and ‘frontend_class’ columns for your attribute and do the same thing without writing a single line of code.

frontend_input = ‘checkbox’
frontend_label = ‘Your checkbox label goes here’
frontend_class = ‘Any CSS class you want applied to the checkbox element

Disclaimer:  I haven’t tried this myself, but it looks like the ‘correct’ way to do it.  Of course, developer documentation would rock. =)

 
Magento Community Magento Community
Magento Community
Magento Community
 
Vinai
Sr. Member
 
Avatar
Total Posts:  218
Joined:  2008-04-04
Heidelberg, Germany
 

Hmmm, white magic ^^
OK, I’ll try that as soon as I’m back next week thursday. Sounds cool.

I would never have thought that “frontend_class” applies to a css class - I naturally thought of a php class…

Thanks,

Vinai

 
Magento Community Magento Community
Magento Community
Magento Community
 
deXXmd
Jr. Member
 
Total Posts:  24
Joined:  2009-04-15
 
Lee Saferite - 27 August 2008 11:56 AM

One trick is to look at the ‘source_model’ column of the attribute in the ‘eav_attribute’ table.  This corresponds to a Model class.

This show how the Tax Class attribute dropdown is populated

SELECT FROM magento.eav_attribute where attribute_code 'tax_class_id'

It uses this model class: Mage_Tax_Model_Class_Source_Product

Try looking at that and see if it helps

I followed your directions and i successfully solved my problem with creating a drop-down with options filled from my own module (Vendors). I want to thank you for your magic post, so short, but so damn informative, thanks!

If anyone interested, I needed to store more information about Vendors, not just a attribute within the product attribute_set. So i created my own Module ( using ModuleCreator), it has Add / Edit / Delete functionality, the only problem i had was to link my Vendors to the product, so that an Administrator using the Admin console of Magento could just select the right Vendor from a drop-down for any product entered / edited.

Good luck!

 
Magento Community Magento Community
Magento Community
Magento Community
 
EvanBrassart
Jr. Member
 
Total Posts:  13
Joined:  2008-08-19
Dallas, Texas
 

@vinai-kung: Can you post some code?  I am attempting to add a few customer attributes and I am totally lost.

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