Example #1
0
<?php

$id = isset($vars[1]) ? $vars[1] : null;
$object = Project::findById($id);
if (is_null($object)) {
    HTML::forward('core/404');
}
// bootstrap field widgets
FormWidgetImage::bootstrap('images');
FormWidgetImage::bootstrap('thumbnail');
FormWidgetDatepicker::bootstrap('date');
FormWidgetPlupfile::bootstrap('attachment');
FormWidgetPlupfile::bootstrap('application');
// handle form submission
if (isset($_POST['submit'])) {
    $error_flag = false;
    /// validation
    // validation for $title
    $title = isset($_POST["title"]) ? strip_tags($_POST["title"]) : null;
    if (empty($title)) {
        Message::register(new Message(Message::DANGER, i18n(array("en" => "title is required.", "zh" => "请填写title"))));
        $error_flag = true;
    }
    if (strlen($title) >= 150) {
        Message::register(new Message(Message::DANGER, i18n(array("en" => "Max length for title is 150", "zh" => "title 不能超过150个字符"))));
        $error_flag = true;
    }
    // validation for $password
    $password = isset($_POST["password"]) ? strip_tags($_POST["password"]) : null;
    $retype_password = isset($_POST["retype_password"]) ? strip_tags($_POST["retype_password"]) : null;
    if (empty($password)) {
Example #2
0
 /**
  * testFindById method
  *
  * @return void
  */
 public function testFindById()
 {
     $data = $this->Project->findById(1);
     $this->assertEqual($data['Project']['name'], 'eCookbook');
     $this->assertEquals($this->Project->findById(100), array());
 }