How to display a dropdown -customer attribute- in customer registration form?












0















I still cannot figure out how to display the dropdown on the customer registration form at app/design/frontend/base/default/template/persistent/customer/form/register.phtml



Any ideas how?



Setup file:



    <?php
$installer = $this;
$installer->startSetup();


$installer->addAttribute("customer", "customer_group", array(
"type" => "int",
"backend" => "",
"label" => "Customer Group",
"input" => "select",
"source" => "customerattribute/eav_entity_attribute_source_customeroptions15505846310",
"visible" => true,
"required" => false,
"default" => "Business",
"frontend" => "",
"unique" => false,
"note" => ""

));

$attribute = Mage::getSingleton("eav/config")->getAttribute("customer", "customer_group");


$used_in_forms=array();

$used_in_forms="adminhtml_customer";
$used_in_forms="checkout_register";
$used_in_forms="customer_account_create";
$used_in_forms="customer_account_edit";
$used_in_forms="adminhtml_checkout";
$attribute->setData("used_in_forms", $used_in_forms)
->setData("is_used_for_customer_segment", true)
->setData("is_system", 0)
->setData("is_user_defined", 1)
->setData("is_visible", 1)
->setData("sort_order", 100)
;
$attribute->save();



$installer->endSetup();


Source file:



<?php
class CustomerAttribute_Model_Eav_Entity_Attribute_Source_Customeroptions15505846310 extends Mage_Eav_Model_Entity_Attribute_Source_Abstract
{
/**
* Retrieve all options array
*
* @return array
*/
public function getAllOptions()
{
if (is_null($this->_options)) {
$this->_options = array(

array(
"label" => Mage::helper("eav")->__("Business"),
"value" => 1
),

array(
"label" => Mage::helper("eav")->__("Personal"),
"value" => 2
),

array(
"label" => Mage::helper("eav")->__("Institution"),
"value" => 3
),

);
}
return $this->_options;
}

/**
* Retrieve option array
*
* @return array
*/
public function getOptionArray()
{
$_options = array();
foreach ($this->getAllOptions() as $option) {
$_options[$option["value"]] = $option["label"];
}
return $_options;
}

/**
* Get a text for option value
*
* @param string|integer $value
* @return string
*/
public function getOptionText($value)
{
$options = $this->getAllOptions();
foreach ($options as $option) {
if ($option["value"] == $value) {
return $option["label"];
}
}
return false;
}

/**
* Retrieve Column(s) for Flat
*
* @return array
*/
public function getFlatColums()
{
$columns = array();
$columns[$this->getAttribute()->getAttributeCode()] = array(
"type" => "tinyint(1)",
"unsigned" => false,
"is_null" => true,
"default" => null,
"extra" => null
);

return $columns;
}

/**
* Retrieve Indexes(s) for Flat
*
* @return array
*/
public function getFlatIndexes()
{
$indexes = array();

$index = "IDX_" . strtoupper($this->getAttribute()->getAttributeCode());
$indexes[$index] = array(
"type" => "index",
"fields" => array($this->getAttribute()->getAttributeCode())
);

return $indexes;
}

/**
* Retrieve Select For Flat Attribute update
*
* @param int $store
* @return Varien_Db_Select|null
*/
public function getFlatUpdateSelect($store)
{
return Mage::getResourceModel("eav/entity_attribute")
->getFlatUpdateSelect($this->getAttribute(), $store);
}
}









share|improve this question



























    0















    I still cannot figure out how to display the dropdown on the customer registration form at app/design/frontend/base/default/template/persistent/customer/form/register.phtml



    Any ideas how?



    Setup file:



        <?php
    $installer = $this;
    $installer->startSetup();


    $installer->addAttribute("customer", "customer_group", array(
    "type" => "int",
    "backend" => "",
    "label" => "Customer Group",
    "input" => "select",
    "source" => "customerattribute/eav_entity_attribute_source_customeroptions15505846310",
    "visible" => true,
    "required" => false,
    "default" => "Business",
    "frontend" => "",
    "unique" => false,
    "note" => ""

    ));

    $attribute = Mage::getSingleton("eav/config")->getAttribute("customer", "customer_group");


    $used_in_forms=array();

    $used_in_forms="adminhtml_customer";
    $used_in_forms="checkout_register";
    $used_in_forms="customer_account_create";
    $used_in_forms="customer_account_edit";
    $used_in_forms="adminhtml_checkout";
    $attribute->setData("used_in_forms", $used_in_forms)
    ->setData("is_used_for_customer_segment", true)
    ->setData("is_system", 0)
    ->setData("is_user_defined", 1)
    ->setData("is_visible", 1)
    ->setData("sort_order", 100)
    ;
    $attribute->save();



    $installer->endSetup();


    Source file:



    <?php
    class CustomerAttribute_Model_Eav_Entity_Attribute_Source_Customeroptions15505846310 extends Mage_Eav_Model_Entity_Attribute_Source_Abstract
    {
    /**
    * Retrieve all options array
    *
    * @return array
    */
    public function getAllOptions()
    {
    if (is_null($this->_options)) {
    $this->_options = array(

    array(
    "label" => Mage::helper("eav")->__("Business"),
    "value" => 1
    ),

    array(
    "label" => Mage::helper("eav")->__("Personal"),
    "value" => 2
    ),

    array(
    "label" => Mage::helper("eav")->__("Institution"),
    "value" => 3
    ),

    );
    }
    return $this->_options;
    }

    /**
    * Retrieve option array
    *
    * @return array
    */
    public function getOptionArray()
    {
    $_options = array();
    foreach ($this->getAllOptions() as $option) {
    $_options[$option["value"]] = $option["label"];
    }
    return $_options;
    }

    /**
    * Get a text for option value
    *
    * @param string|integer $value
    * @return string
    */
    public function getOptionText($value)
    {
    $options = $this->getAllOptions();
    foreach ($options as $option) {
    if ($option["value"] == $value) {
    return $option["label"];
    }
    }
    return false;
    }

    /**
    * Retrieve Column(s) for Flat
    *
    * @return array
    */
    public function getFlatColums()
    {
    $columns = array();
    $columns[$this->getAttribute()->getAttributeCode()] = array(
    "type" => "tinyint(1)",
    "unsigned" => false,
    "is_null" => true,
    "default" => null,
    "extra" => null
    );

    return $columns;
    }

    /**
    * Retrieve Indexes(s) for Flat
    *
    * @return array
    */
    public function getFlatIndexes()
    {
    $indexes = array();

    $index = "IDX_" . strtoupper($this->getAttribute()->getAttributeCode());
    $indexes[$index] = array(
    "type" => "index",
    "fields" => array($this->getAttribute()->getAttributeCode())
    );

    return $indexes;
    }

    /**
    * Retrieve Select For Flat Attribute update
    *
    * @param int $store
    * @return Varien_Db_Select|null
    */
    public function getFlatUpdateSelect($store)
    {
    return Mage::getResourceModel("eav/entity_attribute")
    ->getFlatUpdateSelect($this->getAttribute(), $store);
    }
    }









    share|improve this question

























      0












      0








      0








      I still cannot figure out how to display the dropdown on the customer registration form at app/design/frontend/base/default/template/persistent/customer/form/register.phtml



      Any ideas how?



      Setup file:



          <?php
      $installer = $this;
      $installer->startSetup();


      $installer->addAttribute("customer", "customer_group", array(
      "type" => "int",
      "backend" => "",
      "label" => "Customer Group",
      "input" => "select",
      "source" => "customerattribute/eav_entity_attribute_source_customeroptions15505846310",
      "visible" => true,
      "required" => false,
      "default" => "Business",
      "frontend" => "",
      "unique" => false,
      "note" => ""

      ));

      $attribute = Mage::getSingleton("eav/config")->getAttribute("customer", "customer_group");


      $used_in_forms=array();

      $used_in_forms="adminhtml_customer";
      $used_in_forms="checkout_register";
      $used_in_forms="customer_account_create";
      $used_in_forms="customer_account_edit";
      $used_in_forms="adminhtml_checkout";
      $attribute->setData("used_in_forms", $used_in_forms)
      ->setData("is_used_for_customer_segment", true)
      ->setData("is_system", 0)
      ->setData("is_user_defined", 1)
      ->setData("is_visible", 1)
      ->setData("sort_order", 100)
      ;
      $attribute->save();



      $installer->endSetup();


      Source file:



      <?php
      class CustomerAttribute_Model_Eav_Entity_Attribute_Source_Customeroptions15505846310 extends Mage_Eav_Model_Entity_Attribute_Source_Abstract
      {
      /**
      * Retrieve all options array
      *
      * @return array
      */
      public function getAllOptions()
      {
      if (is_null($this->_options)) {
      $this->_options = array(

      array(
      "label" => Mage::helper("eav")->__("Business"),
      "value" => 1
      ),

      array(
      "label" => Mage::helper("eav")->__("Personal"),
      "value" => 2
      ),

      array(
      "label" => Mage::helper("eav")->__("Institution"),
      "value" => 3
      ),

      );
      }
      return $this->_options;
      }

      /**
      * Retrieve option array
      *
      * @return array
      */
      public function getOptionArray()
      {
      $_options = array();
      foreach ($this->getAllOptions() as $option) {
      $_options[$option["value"]] = $option["label"];
      }
      return $_options;
      }

      /**
      * Get a text for option value
      *
      * @param string|integer $value
      * @return string
      */
      public function getOptionText($value)
      {
      $options = $this->getAllOptions();
      foreach ($options as $option) {
      if ($option["value"] == $value) {
      return $option["label"];
      }
      }
      return false;
      }

      /**
      * Retrieve Column(s) for Flat
      *
      * @return array
      */
      public function getFlatColums()
      {
      $columns = array();
      $columns[$this->getAttribute()->getAttributeCode()] = array(
      "type" => "tinyint(1)",
      "unsigned" => false,
      "is_null" => true,
      "default" => null,
      "extra" => null
      );

      return $columns;
      }

      /**
      * Retrieve Indexes(s) for Flat
      *
      * @return array
      */
      public function getFlatIndexes()
      {
      $indexes = array();

      $index = "IDX_" . strtoupper($this->getAttribute()->getAttributeCode());
      $indexes[$index] = array(
      "type" => "index",
      "fields" => array($this->getAttribute()->getAttributeCode())
      );

      return $indexes;
      }

      /**
      * Retrieve Select For Flat Attribute update
      *
      * @param int $store
      * @return Varien_Db_Select|null
      */
      public function getFlatUpdateSelect($store)
      {
      return Mage::getResourceModel("eav/entity_attribute")
      ->getFlatUpdateSelect($this->getAttribute(), $store);
      }
      }









      share|improve this question














      I still cannot figure out how to display the dropdown on the customer registration form at app/design/frontend/base/default/template/persistent/customer/form/register.phtml



      Any ideas how?



      Setup file:



          <?php
      $installer = $this;
      $installer->startSetup();


      $installer->addAttribute("customer", "customer_group", array(
      "type" => "int",
      "backend" => "",
      "label" => "Customer Group",
      "input" => "select",
      "source" => "customerattribute/eav_entity_attribute_source_customeroptions15505846310",
      "visible" => true,
      "required" => false,
      "default" => "Business",
      "frontend" => "",
      "unique" => false,
      "note" => ""

      ));

      $attribute = Mage::getSingleton("eav/config")->getAttribute("customer", "customer_group");


      $used_in_forms=array();

      $used_in_forms="adminhtml_customer";
      $used_in_forms="checkout_register";
      $used_in_forms="customer_account_create";
      $used_in_forms="customer_account_edit";
      $used_in_forms="adminhtml_checkout";
      $attribute->setData("used_in_forms", $used_in_forms)
      ->setData("is_used_for_customer_segment", true)
      ->setData("is_system", 0)
      ->setData("is_user_defined", 1)
      ->setData("is_visible", 1)
      ->setData("sort_order", 100)
      ;
      $attribute->save();



      $installer->endSetup();


      Source file:



      <?php
      class CustomerAttribute_Model_Eav_Entity_Attribute_Source_Customeroptions15505846310 extends Mage_Eav_Model_Entity_Attribute_Source_Abstract
      {
      /**
      * Retrieve all options array
      *
      * @return array
      */
      public function getAllOptions()
      {
      if (is_null($this->_options)) {
      $this->_options = array(

      array(
      "label" => Mage::helper("eav")->__("Business"),
      "value" => 1
      ),

      array(
      "label" => Mage::helper("eav")->__("Personal"),
      "value" => 2
      ),

      array(
      "label" => Mage::helper("eav")->__("Institution"),
      "value" => 3
      ),

      );
      }
      return $this->_options;
      }

      /**
      * Retrieve option array
      *
      * @return array
      */
      public function getOptionArray()
      {
      $_options = array();
      foreach ($this->getAllOptions() as $option) {
      $_options[$option["value"]] = $option["label"];
      }
      return $_options;
      }

      /**
      * Get a text for option value
      *
      * @param string|integer $value
      * @return string
      */
      public function getOptionText($value)
      {
      $options = $this->getAllOptions();
      foreach ($options as $option) {
      if ($option["value"] == $value) {
      return $option["label"];
      }
      }
      return false;
      }

      /**
      * Retrieve Column(s) for Flat
      *
      * @return array
      */
      public function getFlatColums()
      {
      $columns = array();
      $columns[$this->getAttribute()->getAttributeCode()] = array(
      "type" => "tinyint(1)",
      "unsigned" => false,
      "is_null" => true,
      "default" => null,
      "extra" => null
      );

      return $columns;
      }

      /**
      * Retrieve Indexes(s) for Flat
      *
      * @return array
      */
      public function getFlatIndexes()
      {
      $indexes = array();

      $index = "IDX_" . strtoupper($this->getAttribute()->getAttributeCode());
      $indexes[$index] = array(
      "type" => "index",
      "fields" => array($this->getAttribute()->getAttributeCode())
      );

      return $indexes;
      }

      /**
      * Retrieve Select For Flat Attribute update
      *
      * @param int $store
      * @return Varien_Db_Select|null
      */
      public function getFlatUpdateSelect($store)
      {
      return Mage::getResourceModel("eav/entity_attribute")
      ->getFlatUpdateSelect($this->getAttribute(), $store);
      }
      }






      magento-1.9 customer customer-attribute






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 9 hours ago









      Julian MurilloJulian Murillo

      1599




      1599






















          0






          active

          oldest

          votes











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "479"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f262529%2fhow-to-display-a-dropdown-customer-attribute-in-customer-registration-form%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Magento Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f262529%2fhow-to-display-a-dropdown-customer-attribute-in-customer-registration-form%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Magento 2 controller redirect on button click in phtml file

          Polycentropodidae