Returns the available edit fields.
Description
See also
Return
(array) Associative array of <code>$field_slug => $field_args</code> pairs.
Source
File: src/db-objects/submissions/submission-edit-page.php
protected function get_fields() { $fields = array( 'form_id' => array( 'section' => 'associated_data', 'type' => 'autocomplete', 'label' => __( 'Form', 'torro-forms' ), 'description' => __( 'Specify the form this should be a submission for.', 'torro-forms' ), 'autocomplete' => array( 'rest_placeholder_search_route' => 'torro/v1/forms?search=%search%', 'rest_placeholder_label_route' => 'torro/v1/forms/%value%', 'value_generator' => '%id%', 'label_generator' => '%title%', ), 'required' => true, ), 'user_id' => array( 'section' => 'associated_data', 'type' => 'autocomplete', 'label' => __( 'User', 'torro-forms' ), 'description' => __( 'Specify the user who should be associated with this submission.', 'torro-forms' ), 'autocomplete' => array( 'rest_placeholder_search_route' => 'wp/v2/users?search=%search%', 'rest_placeholder_label_route' => 'wp/v2/users/%value%', 'value_generator' => '%id%', 'label_generator' => '%name%', ), ), 'remote_addr' => array( 'section' => 'identification_data', 'type' => 'text', 'label' => __( 'IP Address', 'torro-forms' ), 'description' => __( 'Specify the IP address where this submission should be sent from.', 'torro-forms' ), 'input_classes' => array( 'regular-text' ), 'pattern' => '\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}', ), 'user_key' => array( 'section' => 'identification_data', 'type' => 'text', 'label' => __( 'Key', 'torro-forms' ), 'description' => __( 'Specify the key identifying the submission creator.', 'torro-forms' ), 'input_classes' => array( 'regular-text' ), ), ); $primary_property = $this->model_manager->get_primary_property(); $id = isset( $_REQUEST[ $primary_property ] ) ? absint( $_REQUEST[ $primary_property ] ) : null; if ( $id ) { $submission = $this->model_manager->get( $id ); if ( $submission ) { $form = $this->model_manager->get_parent_manager( 'forms' )->get( $submission->form_id ); if ( $form ) { foreach ( $form->get_containers() as $container ) { foreach ( $container->get_elements() as $element ) { $element_type = $element->get_element_type(); if ( $element_type ) { if ( is_a( $element_type, Non_Input_Element_Type_Interface::class ) ) { continue; } $element_fields = $element_type->get_edit_submission_fields_args( $element ); foreach ( $element_fields as $slug => $args ) { $element_fields[ $slug ]['section'] = 'container_' . $container->id; } $fields = array_merge( $fields, $element_fields ); } } } } } } return $fields; }
Changelog
Version | Description |
---|---|
1.0.0 | Introduced. |