当前位置: 首页>>代码示例>>PHP>>正文


PHP Requirement::validate方法代码示例

本文整理汇总了PHP中Requirement::validate方法的典型用法代码示例。如果您正苦于以下问题:PHP Requirement::validate方法的具体用法?PHP Requirement::validate怎么用?PHP Requirement::validate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Requirement的用法示例。


在下文中一共展示了Requirement::validate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: actionRequirement

 public function actionRequirement()
 {
     $cs = Yii::app()->getClientScript();
     $cs->registerCssFile(Yii::app()->baseUrl . '/css/requirement.css', 'screen');
     $model = new Requirement();
     // uncomment the following code to enable ajax-based validation
     /*
     if(isset($_POST['ajax']) && $_POST['ajax']==='requirement-requirement-form')
     {
         echo CActiveForm::validate($model);
         Yii::app()->end();
     }
     */
     if (isset($_POST['Requirement'])) {
         $model->attributes = $_POST['Requirement'];
         if ($model->validate()) {
             // form inputs are valid, do something here
             return;
         }
     }
     $this->render('requirement', array('model' => $model));
 }
开发者ID:ngdvan,项目名称:lntguitar,代码行数:22,代码来源:SongController.php

示例2: actionPost

 public function actionPost()
 {
     Yii::beginProfile('requirement_post');
     $userId = Yii::app()->user->id;
     $model = new Requirement();
     $modelState = new GeoState();
     $requirementCities = new RequirementCities();
     $requirementAmenities = new RequirementAmenities();
     $requirementPropertyTypes = new RequirementPropertyTypes();
     $requirementBedrooms = new RequirementBedrooms();
     $amenities = null;
     $propertyTypes = null;
     $bedrooms = null;
     $cities = null;
     $this->performAjaxValidation(array($model));
     if (isset($_POST['minsubmit'])) {
         $modelState->attributes = $_POST['GeoState'];
     } elseif (isset($_POST['PostRequirementMin'])) {
         $model->attributes = $_POST['Requirement'];
         if (isset($_POST['GeoCity']['city'])) {
             $cities[0] = $_POST['GeoCity']['city'];
         }
     } elseif (isset($_POST['submit'])) {
         $model->attributes = $_POST['Requirement'];
         $amenities = isset($_POST['amenity_id']) ? $_POST['amenity_id'] : null;
         $propertyTypes = isset($_POST['property_type_id']) ? $_POST['property_type_id'] : null;
         $bedrooms = isset($_POST['bedrooms']) ? $_POST['bedrooms'] : null;
         $cities = isset($_POST['city_id']) ? $_POST['city_id'] : null;
         $valid = true;
         $model->user_id = $userId;
         $valid = $valid && $model->validate();
         if ($propertyTypes == null) {
             $requirementPropertyTypes->addError('property_type_id', 'Property Type cannot be blank.');
             $valid = false;
         }
         if ($cities == null || empty($cities) || $cities[0] == '') {
             $requirementCities->addError('city_id', 'City cannot be blank.');
             $valid = false;
         }
         if ($valid) {
             $data = $_POST['Requirement'];
             if ($data['covered_area_from'] == null) {
                 $data['covered_area_from'] == 0;
             }
             if ($data['min_price'] == null) {
                 $data['min_price'] = 0;
             }
             $requirement = RequirementApi::createRequirement($userId, $data);
             if (!$requirement->hasErrors()) {
                 $addAmenities = true;
                 $addCities = true;
                 $addBedrooms = true;
                 $addPropertyTypes = true;
                 if (isset($_POST['amenity_id'])) {
                     $addAmenities = RequirementAmenitiesApi::addAmenitiesForRequirement($requirement->id, $_POST['amenity_id']);
                 }
                 if (isset($_POST['city_id'])) {
                     $addCities = RequirementCitiesApi::addCitiesForRequirement($requirement->id, $_POST['city_id']);
                 }
                 if (isset($_POST['bedrooms']) && !empty($_POST['bedrooms'])) {
                     $addBedrooms = RequirementBedroomsApi::addBedroomForRequirement($requirement->id, $_POST['bedrooms']);
                 }
                 if (isset($_POST['property_type_id'])) {
                     $addPropertyTypes = RequirementPropertyTypesApi::addPropertyTypesForRequirement($requirement->id, $_POST['property_type_id']);
                 }
                 if ($addAmenities && $addCities && $addBedrooms && $addPropertyTypes) {
                     //$this->refresh();
                     $this->redirect('/requirement/' . $requirement->id);
                 } else {
                     RequirementAmenitiesApi::deleteAllAmenitiesForRequirement($requirement->id);
                     RequirementCitiesApi::deleteAllCitiesForRequirement($requirement->id);
                     RequirementBedroomsApi::deleteAllBedroomsForRequirement($requirement->id);
                     RequirementPropertyTypesApi::deleteAllPropertyTypesForRequirement($requirement->id);
                 }
             } else {
                 if (isset($property->id)) {
                     PropertyApi::deletePropertyById($property->id);
                 }
             }
         }
     }
     $this->render('post', array('model' => $model, 'modelState' => $modelState, 'requirementCities' => $requirementCities, 'requirementAmenities' => $requirementAmenities, 'requirementPropertyTypes' => $requirementPropertyTypes, 'requirementBedrooms' => $requirementBedrooms, 'amenities' => $amenities, 'propertyTypes' => $propertyTypes, 'bedrooms' => $bedrooms, 'cities' => $cities));
     Yii::endProfile('requirement_post');
 }
开发者ID:romeo14,项目名称:wallfeet,代码行数:84,代码来源:RequirementController.php


注:本文中的Requirement::validate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。