/** * Populate Element * * @param BaseElementModel $element Element * @param Request $request Request * * @return BaseElementModel Element */ public function populateElement(BaseElementModel $element, Request $request) { $fields_key = \Craft\craft()->config->get('contentModelFieldsLocation', 'restfulApi'); $attributes = $request->getParsedBody(); $element->setAttributes($attributes); if (isset($attributes[$fields_key])) { if (isset($attributes[$fields_key]['title'])) { $element->getContent()->title = $attributes[$fields_key]['title']; } $element->setContent($attributes[$fields_key]); } return $element; }