本文整理汇总了PHP中Cliente::validate方法的典型用法代码示例。如果您正苦于以下问题:PHP Cliente::validate方法的具体用法?PHP Cliente::validate怎么用?PHP Cliente::validate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cliente
的用法示例。
在下文中一共展示了Cliente::validate方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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->aCliente !== null) {
if (!$this->aCliente->validate($columns)) {
$failureMap = array_merge($failureMap, $this->aCliente->getValidationFailures());
}
}
if ($this->aProducto !== null) {
if (!$this->aProducto->validate($columns)) {
$failureMap = array_merge($failureMap, $this->aProducto->getValidationFailures());
}
}
if (($retval = VentaPeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
$this->alreadyInValidation = false;
}
return !empty($failureMap) ? $failureMap : true;
}
示例2: actionAjaxSave
public function actionAjaxSave()
{
if (Yii::app()->request->isAjaxRequest) {
$model = new Cliente();
$model->attributes = $_POST['Cliente'];
$modelUsuario = new Usuario();
$modelUsuario->attributes = $_POST['Usuario'];
$modelUsuario->tipo_cliente = 0;
if ($modelUsuario->validate() && $model->validate()) {
if ($model->save()) {
$modelUsuario->cliente_id = $model->id;
if ($modelUsuario->save()) {
Yii::app()->session['id-cliente'] = $model->id;
echo true;
}
}
} else {
echo false;
}
Yii::app()->end();
} else {
throw new CHttpException(400);
}
}
示例3: 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 aggregated 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> objects 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 corresponding set
// method. This object relates to these object(s) by a
// foreign key reference.
if ($this->aCliente !== null) {
if (!$this->aCliente->validate($columns)) {
$failureMap = array_merge($failureMap, $this->aCliente->getValidationFailures());
}
}
if ($this->aProveedorcliente !== null) {
if (!$this->aProveedorcliente->validate($columns)) {
$failureMap = array_merge($failureMap, $this->aProveedorcliente->getValidationFailures());
}
}
if (($retval = ExpedientePeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
if ($this->collExpedienteanticipos !== null) {
foreach ($this->collExpedienteanticipos as $referrerFK) {
if (!$referrerFK->validate($columns)) {
$failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
}
}
}
if ($this->collExpedientearchivos !== null) {
foreach ($this->collExpedientearchivos as $referrerFK) {
if (!$referrerFK->validate($columns)) {
$failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
}
}
}
if ($this->collExpedientegastos !== null) {
foreach ($this->collExpedientegastos as $referrerFK) {
if (!$referrerFK->validate($columns)) {
$failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
}
}
}
if ($this->collExpedienteservicios !== null) {
foreach ($this->collExpedienteservicios as $referrerFK) {
if (!$referrerFK->validate($columns)) {
$failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
}
}
}
$this->alreadyInValidation = false;
}
return !empty($failureMap) ? $failureMap : true;
}
示例4: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model = new Cliente();
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['Cliente'])) {
$model->attributes = $_POST['Cliente'];
$model->direccion_alternativa = $_POST['Cliente']['direccion_alternativa'];
$usuario = new Usuario();
$model->rut = Tools::removeDots($model->rut);
$usuario->user = $model->rut;
$arr = explode("-", $model->rut);
$usuario->clave = CPasswordHelper::hashPassword($arr[0]);
$usuario->rol = "cliente";
$usuario->nombre = $_POST['Cliente']['nombre'];
$usuario->email = $_POST['Cliente']['email'];
$usuario->apellido = $_POST['Cliente']['apellido'];
$model->usuario_id = 1;
if ($model->validate()) {
if ($usuario->validate()) {
if ($usuario->save()) {
$model->usuario_id = $usuario->id;
if ($model->save()) {
$ok = false;
$auth = Yii::app()->authManager;
Authassignment::model()->deleteAllByAttributes(array('userid' => $usuario->id));
$auth->revoke($usuario->rol, $model->usuario_id);
$auth->assign($usuario->rol, $model->usuario_id);
$fiador = new Fiador();
if (isset($_POST['Cliente']['fiador_rut'])) {
if (isset($_POST['Cliente']['fiador_rut'])) {
$fiador->rut = $_POST['Cliente']['fiador_rut'];
$fiador->rut = Tools::removeDots($fiador->rut);
$fiador->nombre = $_POST['Cliente']['fiador_nombre'];
$fiador->apellido = $_POST['Cliente']['fiador_apellido'];
$fiador->email = $_POST['Cliente']['fiador_email'];
$fiador->telefono = $_POST['Cliente']['fiador_telefono'];
$fiador->direccion = $_POST['Cliente']['fiador_direccion'];
if ($fiador->validate()) {
if ($fiador->save()) {
$ok = true;
}
} else {
echo "<br>";
echo CHtml::errorSummary($fiador);
}
}
}
if ($ok) {
$cliente_fiador = new ClienteFiador();
$cliente_fiador->cliente_id = $model->id;
$cliente_fiador->fiador_id = $fiador->id;
$cliente_fiador->save();
}
$this->redirect(array('view', 'id' => $model->id));
}
}
} else {
echo "<br>";
echo CHtml::errorSummary($usuario);
}
} else {
echo "<br>";
echo CHtml::errorSummary($model);
}
}
$this->render('create', array('model' => $model));
}