public function test_humanize() { $input = "an_underscored_word"; $input2 = "a-dashed-word"; $this->assertEqual(WXInflections::humanize($input), "An underscored word"); $this->assertEqual(WXInflections::humanize($input2), "A dashed word"); }
public function error_messages_for($object) { if ($object instanceof WaxForm) { if ($object->bound_to_model) { if ($object->bound_to_model->errors) { $html = "<ul class='user_errors'>"; } foreach ($object->bound_to_model->errors as $err => $mess) { $html .= "<li>" . $mess[0]; } } else { foreach ($object->elements as $el) { foreach ($el->errors as $er) { $html .= sprintf($er->error_template, $er); } } } $html .= "</ul>"; return $html; } if (strpos($object, "_")) { $object = camelize($object, 1); } $class = new $object(); $errors = $class->get_errors(); foreach ($errors as $error) { $html .= $this->content_tag("li", WXInflections::humanize($error['field']) . " " . $error['message'], array("class" => "user_error")); } if (count($errors) > 0) { return $this->content_tag("ul", $html, array("class" => "user_errors")); } return false; }