/** * Check whether the current value for this field conforms. * Doesn't return a value. Just record conformance violations with {@link FORM::record_error()}. * @see FORM::record_error() * @param FORM $form */ public function validate($form) { if ($this->required && $this->is_empty()) { $form->record_error($this->id, "Please provide a value for {$this->caption}."); } }
/** * Make sure data is correct. * @param FORM $form * @param stdClass $obj */ public function validate($form, $obj) { $user_list = $form->value_for($this->base_name); if ($user_list) { $user_query = $this->app->user_query(); $user_names = explode(';', $user_list); $user_ids = array(); foreach ($user_names as $name) { $user = $user_query->object_at_name($name); if (!$user) { $form->record_error($this->base_name, "[{$name}] does not exist."); } else { $user_ids[] = $user->id; } } if (sizeof($user_ids) > 0) { $form->set_value($this->ids_name(), join(',', $user_ids)); } } }