Opened 10 years ago
Closed 10 years ago
#28207 closed defect (bug) (duplicate)
$extra_fields of request_filesystem_credentials does not accept array's
Reported by: | bassjobsen | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.9.1 |
Component: | Filesystem API | Keywords: | |
Focuses: | Cc: |
Description
If my form for instance contains:
<input type="text" name="test[]"> <input type="text" name="test[]">
i can not add test
to $extra_fields
possible solution:
/*foreach ( (array) $extra_fields as $field ) { if ( isset( $_POST[ $field ] ) ) echo '<input type="hidden" name="' . esc_attr( $field ) . '" value="' . esc_attr( wp_unslash( $_POST[ $field ] ) ) . '" />'; }*/ foreach ( (array) $extra_fields as $field ) { if ( isset( $_POST[ $field ] ) ) { if(is_array($_POST[ $field ])) { foreach($_POST[ $field ] as $key=>$value) { echo '<input type="hidden" name="' . esc_attr( $field ) . '[' .esc_attr( $key ). ']" value="' . esc_attr( wp_unslash( $value ) ) . '" />'; } } else { echo '<input type="hidden" name="' . esc_attr( $field ) . '" value="' . esc_attr( wp_unslash( $_POST[ $field ] ) ) . '" />'; } } }
Change History (2)
Note: See
TracTickets for help on using
tickets.
For multidimensional arrays some recursion will be needed too: