0

I need to add select input in registration from in magento 2 I did all the steps but in InstallData.php file I have this partial code

  $eavSetup->addAttribute(Customer::ENTITY, 'account_type', [
        // Attribute parameters
        'type' => 'int',
        'label' => 'Account Type',
        'input' => 'select',
        'required' => true,
        'visible' => true,
        'user_defined' => true,
        'sort_order' => 990,
        'position' => 990,
        'system' => 0,
        'source' => 'Magento\Eav\Model\Entity\Attribute\Source\Table',
        'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_GLOBAL,
        'option' => ['values' => [1=>'Customer', 2=>'Designer or Architect']],
        'is_used_in_grid' => 1,
        'is_visible_in_grid' => 1,
    ]);

I think it add select's options in db but it doesn't take values in right way it suppose to be 1 and 2 but it shows 4 and 5 like:

  <option data-title="Customer" value="4">Customer</option>
  <option data-title="Designer or Architect" value="5">Designer or Architect</option>

How to make this take the values I defined?

0
$eavSetup->addAttribute(Customer::ENTITY, 'account_type', [
        // Attribute parameters
        'type' => 'text',
        'label' => 'Account Type',
        'input' => 'select',
        'required' => true,
        'visible' => true,
        'user_defined' => true,
        'sort_order' => 990,
        'position' => 990,
        'system' => 0,
        'source' => 'Magento\Eav\Model\Entity\Attribute\Source\Table',
        'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_GLOBAL,
        'option' => ['values' => ['Customer', 'Designer or Architect']],
        'is_used_in_grid' => 1,
        'is_visible_in_grid' => 1,
    ]);
4
  • try this in upgrade data hope it works let me know if any issues
    – mohith
    Apr 3 '19 at 5:04
  • Customer & Designer or Architect are option's labels I need to set values for them 1 and 2 not values 4 and 5 as showed previously Apr 3 '19 at 9:30
  • kindly let me know what you will be doing with values
    – mohith
    Apr 3 '19 at 10:03
  • each option has value and text I need to set option value not auto set Apr 3 '19 at 12:51

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.