Answers.Body: <p>You can set it to <code>':empty:'</code>, as mentioned in the <a href="https://github.com/craftcms/cms/blob/2.6.3000/src/helpers/DbHelper.php#L447" rel="nofollow noreferrer"><code>DbHelper::parseParam()</code></a> documentation.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-12-12T09:22:23.767Z
Answers.LastActivityDate: 2017-12-12T09:22:23.767Z
Answers.UserDisplayName: carlcs
Body: <p>I'm trying to add a source on a custom element type that shows entries with an empty <code>assigned_user_id</code> field. This criteria is not honored and returns the same results as the "All Entries" source. Is there any way to specify a null or empty string criteria value?</p>
  
  <pre><code>public function getSources($context = null)
  {
      $sources = [
          '*' =&gt; [
              'label' =&gt; Craft::t('All Entries'),
              'defaultSort' =&gt; [
                  'test_plugin.dateCreated',
                  'desc'
              ]
          ]
      ];
  
      $sources[] = ['heading' =&gt; 'Assignments'];
  
      $sources['unassigned'] = [
          'label'    =&gt; Craft::t('Unassigned'),
          'criteria' =&gt; ['assigned_user_id' =&gt; '']
      ];
  
      return $sources;
  }
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-12-12T04:59:21.410Z
Comments.Text: Is your `assigned_user_id` a Craft relation or just a simple integer?
Comments.UserDisplayName: Robin Schambach
Tags: <plugin-development><elementtype><sources>
Title: Custom ElementType empty getSource criteria?
ThreadText: # Custom ElementType empty getSource criteria?
  
  (Asked by: username_0 on 2017-12-12)
  
  I'm trying to add a source on a custom element type that shows entries with an empty `assigned_user_id` field. This criteria is not honored and returns the same results as the "All Entries" source. Is there any way to specify a null or empty string criteria value?
  
  ```
  public function getSources($context = null)
  {
      $sources = [
          '*' => [
              'label' => Craft::t('All Entries'),
              'defaultSort' => [
                  'test_plugin.dateCreated',
                  'desc'
              ]
          ]
      ];
  
      $sources[] = ['heading' => 'Assignments'];
  
      $sources['unassigned'] = [
          'label'    => Craft::t('Unassigned'),
          'criteria' => ['assigned_user_id' => '']
      ];
  
      return $sources;
  }
  
  ```
  
  **Tags:** plugin-development, elementtype, sources
  
  > **Comments:**
  > **username_1**: Is your `assigned_user_id` a Craft relation or just a simple integer?  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2017-12-12. Score: 1 | Accepted answer
  
  You can set it to `':empty:'`, as mentioned in the [`DbHelper::parseParam()`](https://github.com/craftcms/cms/blob/2.6.3000/src/helpers/DbHelper.php#L447) documentation.
  
  
  ---
  
  