• Модуль: tasks
  • Путь к файлу: ~/bitrix/modules/tasks/lib/item/subitem.php
  • Класс: BitrixTasksItemSubItem
  • Вызов: SubItem::prepareData
public function prepareData($result)
{
	if($res = parent::prepareData($result))
	{
		$id = $this->getId();
		$field = static::getParentConnectorField();

		// check for correct parent defined
		if(!$id && !$this[$field])
		{
			// this is CREATE and no foreign key passed. it is ok, we can define it by ourselves
			$parent = $this->getParent();
			if($parent)
			{
				$parentId = $parent->getId();
				if(!$parentId)
				{
					$result->getErrors()->add('ILLEGAL_PARENT_ID', 'Attempting to save sub-items without saving parent item, huh?');
				}
				else
				{
					$this[$field] = $parentId;
				}
			}
		}
	}

	return $res;
}