Removes an error from the submission.
Description
See also
Parameters
- $element_id
-
(int) (Required) Element ID to remove an error for.
- $code
-
(string) (Required) Error code to remove.
Return
(bool) True on success, false on failure.
Source
File: src/db-objects/submissions/submission.php
public function remove_error( $element_id, $code ) { if ( ! array_key_exists( 'errors', $this->pending_meta ) ) { if ( $this->primary_property_value() ) { $this->pending_meta['errors'] = $this->manager->get_meta( $this->primary_property_value(), 'errors', true ); } else { $this->pending_meta['errors'] = array(); } } if ( ! is_array( $this->pending_meta['errors'] ) ) { return false; } if ( ! is_array( $this->pending_meta['errors'][ $element_id ] ) ) { return false; } if ( ! is_array( $this->pending_meta['errors'][ $element_id ][ $code ] ) ) { return false; } unset( $this->pending_meta['errors'][ $element_id ][ $code ] ); if ( empty( $this->pending_meta['errors'][ $element_id ] ) ) { unset( $this->pending_meta['errors'][ $element_id ] ); } if ( empty( $this->pending_meta['errors'] ) ) { $this->pending_meta['errors'] = null; } return true; }
Changelog
Version | Description |
---|---|
1.0.0 | Introduced. |