本文整理汇总了PHP中AdminForm::validate方法的典型用法代码示例。如果您正苦于以下问题:PHP AdminForm::validate方法的具体用法?PHP AdminForm::validate怎么用?PHP AdminForm::validate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AdminForm
的用法示例。
在下文中一共展示了AdminForm::validate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionAdmin
public function actionAdmin()
{
$model = new AdminForm();
$frequency = KeyValue::model()->findByPk('newsletter_frequency');
$model->frequency = abs($frequency->value);
if (isset($_POST['AdminForm'])) {
$model->attributes = $_POST['AdminForm'];
if ($model->validate()) {
if (isset($_POST['yt1']) || $frequency->value < 0) {
$frequency->value = -$model->frequency;
} else {
$frequency->value = $model->frequency;
}
$frequency->save();
$this->redirect('admin');
}
}
$newsletter = new Newsletter();
$this->render('admin', array('newsletter' => $newsletter->make(), 'model' => $model));
}
示例2: header
<?php
session_start();
if (isset($_SESSION['type'])) {
if ($_SESSION['type'] != "Administrator") {
header('Location: index.php');
}
} else {
header('Location: index.php');
}
include "models/admin_model.php";
$admins = new AdminForm();
$to_edit = new AdminForm();
if (isset($_POST['add_admin'])) {
$to_edit->load_from_post();
$valid = $to_edit->validate();
if ($_POST['password2'] != $to_edit->fields['password']->value) {
$valid = false;
} else {
$to_edit->fields['password']->hash_pass();
}
if ($valid) {
$to_edit->save();
}
} elseif (isset($_POST['admin_id'])) {
$to_edit->load_by_pk($_POST['admin_id']);
$to_edit->load_from_post();
$valid = $to_edit->validate();
if ($valid) {
$to_edit->save();
$to_edit = new AdminForm();