Example #1
0
<?php

$object = new Project();
// 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)) {
        Message::register(new Message(Message::DANGER, i18n(array("en" => "password is required.", "zh" => "请填写password"))));
        $error_flag = true;
    }
    if (strlen($password) >= 15) {
Example #2
0
<?php

$object = new Application();
// bootstrap field widgets
FormWidgetPlupfile::bootstrap('passport');
FormWidgetPlupfile::bootstrap('graduation_certificate');
FormWidgetPlupfile::bootstrap('degree_certificate');
FormWidgetPlupfile::bootstrap('academic_transcripts');
FormWidgetPlupfile::bootstrap('ielts_transcripts');
// handle form submission
if (isset($_POST['submit'])) {
    $error_flag = false;
    /// validation
    // validation for $name
    $name = isset($_POST["name"]) ? strip_tags($_POST["name"]) : null;
    if (empty($name)) {
        Message::register(new Message(Message::DANGER, i18n(array("en" => "name is required.", "zh" => "请填写name"))));
        $error_flag = true;
    }
    // validation for $dob
    $dob = isset($_POST["dob"]) ? strip_tags($_POST["dob"]) : null;
    if (empty($dob)) {
        Message::register(new Message(Message::DANGER, i18n(array("en" => "dob is required.", "zh" => "请填写dob"))));
        $error_flag = true;
    }
    // validation for $address
    $address = isset($_POST["address"]) ? strip_tags($_POST["address"]) : null;
    // validation for $postcode
    $postcode = isset($_POST["postcode"]) ? strip_tags($_POST["postcode"]) : null;
    // validation for $phone
    $phone = isset($_POST["phone"]) ? strip_tags($_POST["phone"]) : null;