Bitmasks via enums

Using the BitmaskedBehavior of Tools plugin.

Optional (nullable) field | Required (not nullable) field

Table

Some example records stored in DB

Id Name Flags raw (bitmasked) Flags (array)
1 Careful 8
  • 8 (Flagged)
    Sandbox\Model\Enum\Flag Enum:int ( [name] => Flagged [value] => 8 )
2 I am promoted 6
  • 2 (Featured)
    Sandbox\Model\Enum\Flag Enum:int ( [name] => Featured [value] => 2 )
  • 4 (Approved)
    Sandbox\Model\Enum\Flag Enum:int ( [name] => Approved [value] => 4 )
3 I am a bit more important 7
  • 1 (Important)
    Sandbox\Model\Enum\Flag Enum:int ( [name] => Important [value] => 1 )
  • 2 (Featured)
    Sandbox\Model\Enum\Flag Enum:int ( [name] => Featured [value] => 2 )
  • 4 (Approved)
    Sandbox\Model\Enum\Flag Enum:int ( [name] => Approved [value] => 4 )
4 I have no flags 0
    5 I am everything 15
    • 1 (Important)
      Sandbox\Model\Enum\Flag Enum:int ( [name] => Important [value] => 1 )
    • 2 (Featured)
      Sandbox\Model\Enum\Flag Enum:int ( [name] => Featured [value] => 2 )
    • 4 (Approved)
      Sandbox\Model\Enum\Flag Enum:int ( [name] => Approved [value] => 4 )
    • 8 (Flagged)
      Sandbox\Model\Enum\Flag Enum:int ( [name] => Flagged [value] => 8 )

    Demo for nullable bitmask field `flag_optional`

    Add Entry

    Send your feedback or bugreport!