public function onBeforeWrite() { parent::onBeforeWrite(); if (isset($_POST['ProductAttributes']) && is_array($_POST['ProductAttributes'])) { $this->AttributeValues()->setByIDList(array_values($_POST['ProductAttributes'])); } }