title: Customer custom attribute using EAV is not displaying values in Grid
body: <p><strong>Scenario</strong>  </p>
  
  <p>I'm trying to implement a custom attribute for Magento Customer, that should accept <strong>boolean</strong> values (True/False, Yes/No...).<br>
  I'm using Magento CE 2.2.4.<br>
  This is part of a custom Module under <code>/app/code/TheVendor_TheModule/</code>.<br>
  The other components of the Module are working correctly.</p>
  
  <hr>
  
  <p><strong>Expected Result</strong></p>
  
  <ul>
  <li>The attribute must be represented with a <strong>switch</strong> input or checkbox in back-end Customer form.</li>
  <li>The attribute and its values must appear in Customers Grid</li>
  <li>The attribute must appear in the <strong>Filter</strong> with selectable options (Yes/No or True/False or Is/Is not, any Boolean-like value works fine)</li>
  </ul>
  
  <hr>
  
  <p><strong>Actual Result</strong></p>
  
  <ul>
  <li>[<em>OK</em>] A switch shows in the back-end within the Customer form as expected.</li>
  <li>[<em>OK</em>] Changing the switch value to on or off + saving works fine.</li>
  <li>[<strong>Issue</strong>] The attribute's <code>Label</code> shows in the <strong>Customer Grid</strong> but <strong>the values are missing</strong>.</li>
  <li>[<strong>Issue</strong>] The attribute's input in the <strong>Filter</strong> shows but <strong>does not contain options</strong>.</li>
  </ul>
  
  <hr>
  
  <p><strong>Screens</strong>  </p>
  
  <p>Customer Form View in back-end  </p>
  
  <p><a href="https://i.stack.imgur.com/aIVdC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aIVdC.png" alt="Customer Form View"></a>  </p>
  
  <p>Customer Grid and Filter View  </p>
  
  <p><a href="https://i.stack.imgur.com/hq4qw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hq4qw.png" alt="Customer Grid and Filter View"></a></p>
  
  <hr>
  
  <p><strong>Code</strong>  </p>
  
  <pre><code>&lt;?php
  
  namespace TheVendor\TheModule\Setup;
  
  use Magento\Customer\Setup\CustomerSetupFactory;
  use Magento\Eav\Setup\EavSetup;
  use Magento\Eav\Model\Config;
  use Magento\Eav\Setup\EavSetupFactory;
  use Magento\Framework\Setup\InstallDataInterface;
  use Magento\Framework\Setup\ModuleContextInterface;
  use Magento\Framework\Setup\ModuleDataSetupInterface;
  
  class InstallData implements InstallDataInterface {
  
      const ATTRIBUTE_APPROVED = 'attribute_approved';
  
      protected $customerSetupFactory;
  
      private $eavSetupFactory;
      private $eavConfig;
      private $attributeResource;
  
      public function __construct(
          CustomerSetupFactory $customerSetupFactory, 
          EavSetupFactory $eavSetupFactory, 
          Config $eavConfig, 
          \Magento\Customer\Model\ResourceModel\Attribute $attributeResource
      ){
          $this-&gt;eavSetupFactory = $eavSetupFactory;
          $this-&gt;eavConfig = $eavConfig;
          $this-&gt;customerSetupFactory = $customerSetupFactory;
          $this-&gt;attributeResource = $attributeResource;
      }
  
      public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
      {
          $setup-&gt;startSetup();
  
          /** @var CustomerSetup $customerSetup */
          $customerSetup = $this-&gt;customerSetupFactory-&gt;create(['setup' =&gt; $setup]);
  
          $customerSetup-&gt;addAttribute(\Magento\Customer\Model\Customer::ENTITY, self::ATTRIBUTE_APPROVED, [
              'type' =&gt; 'int',
              'label' =&gt; 'Attribute Approved',
              'input' =&gt; 'boolean',
              'required' =&gt; false,
              'visible' =&gt; true,
              'system' =&gt; false,
              'position' =&gt; 9,
              'sort_order' =&gt; 9,
              'is_used_in_grid' =&gt; true,
              'is_visible_in_grid' =&gt; true,
              'is_filterable_in_grid' =&gt; true,
              'is_searchable_in_grid' =&gt; true,
              //'user_defined' =&gt; true, //commented because causing attribute fail on module install
              //'searchable' =&gt; true,
              'filterable' =&gt; true,
              'comparable' =&gt; true,
              'default' =&gt; '0',
              //'unique' =&gt; 0,
          ]);
  
          $myAttribute = $customerSetup-&gt;getEavConfig()-&gt;getAttribute(\Magento\Customer\Model\Customer::ENTITY, self::ATTRIBUTE_APPROVED);
  
          $myAttribute-&gt;setData('used_in_forms', ['adminhtml_customer']);
  
          $this-&gt;attributeResource-&gt;save($myAttribute);
  
          $setup-&gt;endSetup();
  
      }
  }
  </code></pre>
  
  <hr>
  
  <p><strong>Attempts and Tests</strong>  </p>
  
  <p>I tried the following:</p>
  
  <ul>
  <li>Lookup solution in Magento Dev Docs</li>
  <li>Lookup solution on StackExchange</li>
  <li>Lookup solution on other forums</li>
  <li>Tweaking <code>$customerSetup-&gt;addAttribute(...)</code> options:
  
  <ul>
  <li>Set <code>'user_defined' =&gt; true</code>. When used, this one is causing the attribute setup to fail without errors.</li>
  <li>Set <code>'default' =&gt; 0</code> and <code>'default' =&gt; '0'</code></li>
  <li>Set <code>'searchable' =&gt; true</code></li>
  </ul></li>
  <li>Checked logs for errors, none found.</li>
  <li>Removed the Module folder and create it again before reinstall</li>
  <li>Executed <code>php bin/magento setup:di:compile</code></li>
  <li>Executed <code>php bin/magento setup:static-content:deploy -f</code></li>
  </ul>
  
  <p><strong>Testing Routine</strong>  </p>
  
  <p>For every test that I made I followed these steps to ensure Module is being installed correctly:</p>
  
  <ul>
  <li>Execute <code>php bin/magento module:disable TheVendor_TheModule</code></li>
  <li>Remove records from database:
  
  <ul>
  <li>Delete Module record in <code>mage_setup_module</code></li>
  <li>Delete EAV record in <code>mage_eav_attribute</code></li>
  </ul></li>
  <li>Make sure Module is disabled in <code>app/etc/config.php</code></li>
  <li>Pull updated code</li>
  <li>Execute <code>php bin/magento module:enable TheVendor_TheModule</code></li>
  <li>Execute <code>php bin/magento setup:upgrade</code></li>
  <li>Execute <code>php bin/magento indexer:reindex</code></li>
  <li>Execute <code>php bin/magento cache:clean</code>  </li>
  </ul>
  
  <hr>
  
  <p><strong>Question</strong></p>
  
  <p>Anyone with suggestions on how to handle this or how to detect where the problem is coming from?  </p>