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' => [

    $sources[] = ['heading' => 'Assignments'];

    $sources['unassigned'] = [
        'label'    => Craft::t('Unassigned'),
        'criteria' => ['assigned_user_id' => '']

    return $sources;
  • Is your assigned_user_id a Craft relation or just a simple integer? – Robin Schambach Dec 12 '17 at 4:59

You can set it to ':empty:', as mentioned in the DbHelper::parseParam() documentation.

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.