Filters the array representation of a given element of this type.
Description
See also
Parameters
- $data
-
(array) (Required) Element data to filter.
- $element
-
(awsmug\Torro_Forms\DB_Objects\Elements\Element) (Required) The element object to get the data for.
- $submission
-
(awsmug\Torro_Forms\DB_Objects\Submissions\Submission|null) (Optional) Submission to get the values from, if available.
Default value: null
Return
(array) Array including all information for the element type.
Source
File: src/db-objects/elements/element-types/base/onechoice.php
public function filter_json( $data, $element, $submission = null ) { $data = parent::filter_json( $data, $element, $submission ); if ( ! empty( $data['input_attrs']['required'] ) ) { unset( $data['input_attrs']['required'] ); } if ( ! empty( $data['input_attrs']['aria-required'] ) ) { unset( $data['input_attrs']['aria-required'] ); } $data['legend_attrs'] = $data['label_attrs']; unset( $data['legend_attrs']['for'] ); $data['input_attrs']['id'] = str_replace( (string) $element->id, (string) $element->id . '-%index%', $data['input_attrs']['id'] ); $data['label_attrs']['id'] = str_replace( (string) $element->id, (string) $element->id . '-%index%', $data['label_attrs']['id'] ); $data['label_attrs']['for'] = str_replace( (string) $element->id, (string) $element->id . '-%index%', $data['label_attrs']['for'] ); return $data; }
Changelog
Version | Description |
---|---|
1.0.0 | Introduced. |