Gets all errors, for the entire submission or a specific element.
Description
See also
Parameters
- $element_id
-
(int|null) (Optional) If an element ID is given, only errors for that element are returned.
Default value: null
Return
(array) If $element_id is given, the array of <code>$code => $message</code> pairs is returned. Otherwise the array of <code>$element_id => $errors</code> pairs is returned.
Source
File: src/db-objects/submissions/submission.php
public function get_errors( $element_id = null ) { if ( ! array_key_exists( 'errors', $this->pending_meta ) ) { if ( ! $this->primary_property_value() ) { return array(); } $errors = $this->manager->get_meta( $this->primary_property_value(), 'errors', true ); } else { $errors = $this->pending_meta['errors']; } if ( ! is_array( $errors ) ) { return array(); } if ( null !== $element_id ) { if ( empty( $errors[ $element_id ] ) ) { return array(); } return $errors[ $element_id ]; } return $errors; }
Changelog
Version | Description |
---|---|
1.0.0 | Introduced. |