How to add attribute to customer entity type in Magento / custom select dropdown field in customer registration

https://gist.github.com/jreinke/1678387#file-mysql4-install-0-1-0-php-L4-L18

 <?php
$installer = $this;
$installer->startSetup();
$installer->addAttribute('customer', 'civility', array(
    'label'        => 'Civility',
    'visible'      => true,
    'required'     => false,
    'type'         => 'int',
    'input'        => 'select',
    'user_defined' => '1',
    'source'       => 'eav/entity_attribute_source_table',
));
$tableOptions = $installer->getTable('eav_attribute_option');
$tableOptionValues = $installer->getTable('eav_attribute_option_value');
$attributeId = (int) $installer->getAttribute('customer', 'civility', 'attribute_id');
foreach (array('Mr', 'Mrs', 'Miss') as $sortOrder => $label) {
    $data = array(
        'attribute_id' => $attributeId,
        'sort_order'   => $sortOrder,
    );
    $installer->getConnection()->insert($tableOptions, $data);
    $optionId = (int) $installer->getConnection()->lastInsertId($tableOptions, 'option_id');
    $data = array(
        'option_id' => $optionId,
        'store_id'  => 0,
        'value'     => $label,
    );
    $installer->getConnection()->insert($tableOptionValues, $data);
}
$installer->endSetup();

registration.phtml

  <li>
                    <?php
                    $attribute = Mage::getModel('eav/config')->getAttribute('customer','civility');
                    $options = $attribute->getSource()->getAllOptions();
                    ?>
                    <label for="civility" class="<?php if($attribute->getIsRequired() == true){?>required<?php } ?>"><?php if($attribute->getIsRequired() == true){?><em>*</em><?php } ?><?php echo $this->__('Civility') ?></label>
                    <div class="input-box">
                        <select name="civility" id="civility" class="<?php if($attribute->getIsRequired() == true){?>required-entry<?php } ?>">
                            <?php
                            foreach($options as $option){
                                ?>
                                <option value='<?php echo $option['value']?>' <?php if($this->getFormData()->getCivility() == $option['value']){ echo 'selected="selected"';}?>><?php echo $this->__($option['label'])?></option>

                            <?php } ?>
                        </select>
                    </div>
                </li>

edit.php

  <li>
                    <?php
                    $attribute = Mage::getModel('eav/config')->getAttribute('customer','civility');
                    $options = $attribute->getSource()->getAllOptions();
                    ?>
                    <label for="civility" class="<?php if($attribute->getIsRequired() == true){?>required<?php } ?>"><?php if($attribute->getIsRequired() == true){?><em>*</em><?php } ?><?php echo $this->__('Civility') ?></label>
                    <div class="input-box">
                        <select name="civility" id="civility" class="<?php if($attribute->getIsRequired() == true){?>required-entry<?php } ?>">
                            <?php
                            foreach($options as $option){
                                ?>
                                <option value='<?php echo $option['value']?>' <?php if($this->getCustomer()->getCivility() == $option['value']){ echo 'selected="selected"';}?>><?php echo $this->__($option['label'])?></option>

                            <?php } ?>
                        </select>
                    </div>
                </li>

http://www.blessthemoon.com/magento-eav-model-and-customer-registration-part-4-adding-a-source-model/