本文整理汇总了PHP中Project::validate方法的典型用法代码示例。如果您正苦于以下问题:PHP Project::validate方法的具体用法?PHP Project::validate怎么用?PHP Project::validate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Project
的用法示例。
在下文中一共展示了Project::validate方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'show' page.
*/
public function actionCreate()
{
$model = new Project($this->action->id);
if (isset($_POST['Project'])) {
// collect user input data
$model->attributes = $_POST['Project'];
// validate with the current action as scenario and save without validation
if (($validated = $model->validate()) !== false && ($saved = $model->save(false)) !== false) {
if (isset($_POST['Company2Project'])) {
// assigned companies
$model->allCompany2Project = array(0 => new Company2Project('create'));
$model->allCompany2Project[0]->projectId = $model->id;
foreach ($model->allCompany2Project as $company2Project) {
$company2Project->attributes = $_POST['Company2Project'];
$company2Project->save();
}
}
if (isset($_POST['User2Project'])) {
// assigned managers
$model->allManager2Project = array(0 => new User2Project('create'));
$model->allManager2Project[0]->projectId = $model->id;
foreach ($model->allManager2Project as $user2Project) {
$user2Project->attributes = $_POST['User2Project'];
$user2Project->save();
}
}
// set success message
MUserFlash::setTopSuccess(Yii::t('hint', 'The new "{title}" project record has been successfully created.', array('{title}' => MHtml::wrapInTag($model->title, 'strong'))));
// go to the 'show' page
$this->redirect(array('show', 'id' => $model->id));
}
} else {
// pre-assigned attributes (default values for a new record)
$model->priority = Project::PRIORITY_MEDIUM;
if (isset($_GET['companyId'])) {
// company is known
$model->allCompany2Project = array(0 => new Company2Project('create'));
$model->allCompany2Project[0]->companyId = $_GET['companyId'];
$model->allCompany2Project[0]->projectId = $model->id;
}
}
if (!isset($model->allCompany2Project[0])) {
// new associated company
$model->allCompany2Project = array(0 => new Company2Project('create'));
$model->allCompany2Project[0]->projectId = $model->id;
}
if (!isset($model->allManager2Project[0])) {
// new associated manager
$model->allManager2Project = array(0 => new User2Project('create'));
$model->allManager2Project[0]->projectId = $model->id;
$model->allManager2Project[0]->role = User2Project::MANAGER;
}
$this->render($this->action->id, array('model' => $model));
}
示例2: doValidate
/**
* This function performs the validation work for complex object models.
*
* In addition to checking the current object, all related objects will
* also be validated. If all pass then <code>true</code> is returned; otherwise
* an aggreagated array of ValidationFailed objects will be returned.
*
* @param array $columns Array of column names to validate.
* @return mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise.
*/
protected function doValidate($columns = null)
{
if (!$this->alreadyInValidation) {
$this->alreadyInValidation = true;
$retval = null;
$failureMap = array();
// We call the validate method on the following object(s) if they
// were passed to this object by their coresponding set
// method. This object relates to these object(s) by a
// foreign key reference.
if ($this->aProject !== null) {
if (!$this->aProject->validate($columns)) {
$failureMap = array_merge($failureMap, $this->aProject->getValidationFailures());
}
}
if ($this->aStatus !== null) {
if (!$this->aStatus->validate($columns)) {
$failureMap = array_merge($failureMap, $this->aStatus->getValidationFailures());
}
}
if ($this->aPriority !== null) {
if (!$this->aPriority->validate($columns)) {
$failureMap = array_merge($failureMap, $this->aPriority->getValidationFailures());
}
}
if ($this->aUser !== null) {
if (!$this->aUser->validate($columns)) {
$failureMap = array_merge($failureMap, $this->aUser->getValidationFailures());
}
}
if (($retval = TaskPeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
if ($this->collOverrideTasksRelatedByTaskId !== null) {
foreach ($this->collOverrideTasksRelatedByTaskId as $referrerFK) {
if (!$referrerFK->validate($columns)) {
$failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
}
}
}
if ($this->collOverrideTasksRelatedByOverrideTaskId !== null) {
foreach ($this->collOverrideTasksRelatedByOverrideTaskId as $referrerFK) {
if (!$referrerFK->validate($columns)) {
$failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
}
}
}
$this->alreadyInValidation = false;
}
return !empty($failureMap) ? $failureMap : true;
}
示例3: store
public function store()
{
$title = Input::get('title');
$project = new Project(['title' => $title, 'slug' => Str::slug($title)]);
$validation = $project->validate();
if ($validation->fails()) {
foreach ($validation->messages()->all() as $error) {
Flash::error($error);
}
} elseif ($project->save()) {
Flash::success('Successfully created the new project');
} else {
Flash::error('Could not create the project. Please try again');
}
return Redirect::back();
}
示例4: action_do_create
public function action_do_create()
{
// let's get the new post from the POST data
// this is much safer than using mass assignment
$new = array('name' => Input::get('name'), 'description' => Input::get('description'), 'customer_id' => Input::get('customer_id'), 'organization_id' => Auth::user()->organization->id);
$v = Project::validate($new);
if ($v->fails()) {
// redirect back to the form with
// errors, input and our currently
// logged in user
return Redirect::to_route('create_project')->with('user', Auth::user())->with_errors($v)->with_input();
}
// create the new post
$o = new Project($new);
$o->save();
// redirect to viewing our new post
return Redirect::to_route('projects');
}
示例5: doValidate
/**
* This function performs the validation work for complex object models.
*
* In addition to checking the current object, all related objects will
* also be validated. If all pass then <code>true</code> is returned; otherwise
* an aggreagated array of ValidationFailed objects will be returned.
*
* @param array $columns Array of column names to validate.
* @return mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise.
*/
protected function doValidate($columns = null)
{
if (!$this->alreadyInValidation) {
$this->alreadyInValidation = true;
$retval = null;
$failureMap = array();
// We call the validate method on the following object(s) if they
// were passed to this object by their coresponding set
// method. This object relates to these object(s) by a
// foreign key reference.
if ($this->aProject !== null) {
if (!$this->aProject->validate($columns)) {
$failureMap = array_merge($failureMap, $this->aProject->getValidationFailures());
}
}
if (($retval = BuildPeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
$this->alreadyInValidation = false;
}
return !empty($failureMap) ? $failureMap : true;
}
示例6: createproject
public function createproject()
{
if (isset($this->_user)) {
$view = $this->getActionView();
$manager = User::first(array('id = ?' => $this->_user->id, 'type = ?' => 'manager'));
if (!empty($manager)) {
$clientids = User::all(array('addedby = ?' => $this->user->id));
$view->set('manager', $manager)->set('clientids', $clientids);
}
}
if (RequestMethods::post('createproject')) {
$pro = new Project(array('name' => RequestMethods::post('name'), 'description' => RequestMethods::post('desc'), 'managerid' => $this->user->id, 'clientid' => RequestMethods::post('clientid'), 'est' => RequestMethods::post('est'), 'bill_amount' => RequestMethods::post('amt')));
if ($pro->validate()) {
$pro->save();
$view->set('createproject_e', 'success');
} else {
$view->set('createproject_e', 'validation not good');
}
}
}
示例7: doValidate
/**
* This function performs the validation work for complex object models.
*
* In addition to checking the current object, all related objects will
* also be validated. If all pass then <code>true</code> is returned; otherwise
* an aggreagated array of ValidationFailed objects will be returned.
*
* @param array $columns Array of column names to validate.
* @return mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise.
*/
protected function doValidate($columns = null)
{
if (!$this->alreadyInValidation) {
$this->alreadyInValidation = true;
$retval = null;
$failureMap = array();
// We call the validate method on the following object(s) if they
// were passed to this object by their coresponding set
// method. This object relates to these object(s) by a
// foreign key reference.
if ($this->aPublication !== null) {
if (!$this->aPublication->validate($columns)) {
$failureMap = array_merge($failureMap, $this->aPublication->getValidationFailures());
}
}
if ($this->aProject !== null) {
if (!$this->aProject->validate($columns)) {
$failureMap = array_merge($failureMap, $this->aProject->getValidationFailures());
}
}
if ($this->aStatus !== null) {
if (!$this->aStatus->validate($columns)) {
$failureMap = array_merge($failureMap, $this->aStatus->getValidationFailures());
}
}
if (($retval = JobPeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
if ($this->collJobAttachments !== null) {
foreach ($this->collJobAttachments as $referrerFK) {
if (!$referrerFK->validate($columns)) {
$failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
}
}
}
if ($this->collPhotos !== null) {
foreach ($this->collPhotos as $referrerFK) {
if (!$referrerFK->validate($columns)) {
$failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
}
}
}
if ($this->collDeliverys !== null) {
foreach ($this->collDeliverys as $referrerFK) {
if (!$referrerFK->validate($columns)) {
$failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
}
}
}
if ($this->collJobPhotographers !== null) {
foreach ($this->collJobPhotographers as $referrerFK) {
if (!$referrerFK->validate($columns)) {
$failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
}
}
}
if ($this->collJobClients !== null) {
foreach ($this->collJobClients as $referrerFK) {
if (!$referrerFK->validate($columns)) {
$failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
}
}
}
$this->alreadyInValidation = false;
}
return !empty($failureMap) ? $failureMap : true;
}