public function error_messages_for($obj, $obj_name = "", $obj_prefix = "") { if ($obj->errors && $obj->errors->size()) { if ($obj_name == "") { $obj_name = \ActiveRecord\Utils::singularize(strtolower(get_class($obj))); } if ($obj_prefix == "") { if (\ActiveRecord\Utils::pluralize_if(2, $obj_name) == "2 " . $obj_name) { $obj_prefix = "these"; } else { $obj_prefix = "this"; } } $html = "<p>" . "<div class=\"flash-error\">" . "<strong>" . $obj->errors->size() . " " . h(\ActiveRecord\Utils::pluralize_if($obj->errors->size(), "error")) . " prohibited " . raw_or_h($obj_prefix) . " " . raw_or_h($obj_name) . " from being " . ($obj->is_new_record() ? "created" : "saved") . ":</strong><br />\n"; foreach ($obj->errors as $err) { $html .= raw_or_h($err) . "<br />"; } $html .= "</div>" . "</p>"; return $html; } }