$value = new RatingValue(); $value->setRatingHeader($header); $value->setCategoryOption($option); $value->setOriginalValue($option->getValue()); if ($selected == "adns") { $value->setDoNotScore(true); } if (array_key_exists('comment_' . $option->getId(), $_POST)) { $value->setComments($_POST['comment_' . $option->getId()]); } else { $value->setComments(""); } $value->save($con); if (array_key_exists('sub_option_' . $option->getId(), $_POST)) { $sub_value = new RatingValue(); $sub_value->setRatingHeader($header); $sub_option = CategoryOptionQuery::create()->filterById($_POST['sub_option_' . $option->getId()])->findOne($con); if ($sub_option == null) { throw new Exception("Sub option ID not found: " . $_POST['sub_option_' . $option->getId()]); } $sub_value->setCategoryOption($sub_option); $sub_value->setOriginalValue($sub_option->getValue()); $sub_value->save($con); $score += $sub_option->getValue(); } if (!$value->getDoNotScore()) { $score += $option->getValue(); } } } $header->setUpdated(new DateTime());