1

I want to add new field Title. This field is a Dropdown and I give value like this.

$attributes = array(
'jobtitle'           => array(
    'label'    => 'Title',
    'backend_type'     => 'varchar',
    'frontend_input'    => 'select',
    'is_user_defined'   => 1,
    'is_system'         => 0,
    'is_visible'        => 1,
    'sort_order'        => 140,
    'is_required'       => 1,
    'multiline_count'   => 0,
    'option'            => array (
        'value' => array(
            'Mr' => array('Mr'),
            'Mrs' => array('Mrs'),
            'Ms' => array('Ms'),                                               
            'Miss' => array('Miss'),                                               
            'Dr' => array('Dr'),                                              
            )
    ),
    'validate_rules'    => array(
        'max_text_length'   => 255,
        'min_text_length'   => 1
    ),
),
);

foreach ($attributes as $attributeCode => $data) {
    $attribute = $eavConfig->getAttribute('customer_address', $attributeCode);
    $attribute->setWebsite($store->getWebsite());
    $attribute->addData($data);
        $usedInForms = array(
            'adminhtml_customer_address',
            'customer_address_edit',
            'customer_register_address'
        );
        $attribute->setData('used_in_forms', $usedInForms);
    $attribute->save();
}

There is a options is my dropdown value. when I see in the admin side, field is added and the dropdown is displayed but this value is not set. I am getting the blank Dropdown. Please help.

4

If you are trying to add title in-front of customer name, it's an in-built feature in Magento. Go to System > Configuration. And under Customers tab select customer configurations. See the image below.

enter image description here

  • Thank you. Thank you.Thank you. Thank you. so much thank's. – Renish Khunt May 13 '14 at 11:22
  • 1
    Glad to hear that worked for you :) – Sukeshini May 13 '14 at 11:26
  • hi i want rename prefix to title please where i can change label prefix to title thank's – Renish Khunt May 15 '14 at 5:58
  • While this hits his specific use case, it does not answer the actual question posed (which comes up in search results) - adding a select to a customer address – Navarr Mar 8 '16 at 20:37
1

Try it with 'source' instead of 'option' and create a source model which returns the option values.

The option structrue should look like this:

array(
  array(
     'label' => 'A',
     'value' => 1
  ),
  array(
     'label' => 'B',
     'value' => 2
  )
)

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.