/** * @param ActiveField|SetItemInterface $item * @return string name * @throws \Exception */ protected function getItemName($item) { if ($item instanceof ActiveField || $item instanceof InputWidget) { $name = $item->attribute; } elseif ($item instanceof SetItemInterface) { $name = $item->getName(); } else { throw new \Exception('Unsupported item type'); } return $name; }