00001 <?php
00002
00015
00016
00017
00018 import('form.validation.FormValidatorArray');
00019
00020 class FormValidatorArray extends FormValidator {
00021
00023 var $fields;
00024
00026 var $errorFields;
00027
00034 function FormValidatorArray(&$form, $field, $type, $message, $fields = array()) {
00035 parent::FormValidator($form, $field, $type, $message);
00036 $this->fields = $fields;
00037 $this->errorFields = array();
00038 }
00039
00045 function isValid() {
00046 if ($this->type == 'optional') {
00047 return true;
00048 }
00049
00050 $ret = true;
00051 $data = $this->form->getData($this->field);
00052 if (!is_array($data)) return false;
00053 foreach ($data as $key => $value) {
00054 if (count($this->fields) == 0) {
00055 if (trim($value) == '') {
00056 $ret = false;
00057 array_push($this->errorFields, "{$this->field}[{$key}]");
00058 }
00059
00060 } else {
00061 foreach ($this->fields as $field) {
00062 if (trim($value[$field]) == '') {
00063 $ret = false;
00064 array_push($this->errorFields, "{$this->field}[{$key}][{$field}]");
00065 }
00066 }
00067 }
00068 }
00069
00070 return $ret;
00071 }
00072
00077 function getErrorFields() {
00078 return $this->errorFields;
00079 }
00080
00081 }
00082
00083 ?>