Pledges: Rename input field to match handler expectation.

Previously the field wasn't being saved when a new pledge was created.
This commit is contained in:
Ian Dunn 2019-10-21 12:41:58 -07:00
parent fff279aa34
commit 2927532544
No known key found for this signature in database
GPG key ID: 99B971B50343CBCB
3 changed files with 11 additions and 5 deletions

View file

@ -81,7 +81,7 @@ function process_form_new() {
);
}
$contributors = parse_contributors( $submission['pledge-contributors'] );
$contributors = parse_contributors( $submission['org-pledge-contributors'] );
if ( is_wp_error( $contributors ) ) {
return $contributors;
@ -184,7 +184,7 @@ function get_form_submission() {
wp_list_pluck( PledgeMeta\get_pledge_meta_config( 'user_input' ), 'php_filter' ),
// Inputs with no corresponding meta value.
array(
'pledge-contributors' => FILTER_SANITIZE_STRING,
'org-pledge-contributors' => FILTER_SANITIZE_STRING,
'pledge-agreement' => FILTER_VALIDATE_BOOLEAN,
)
);
@ -246,7 +246,7 @@ function get_pledge_contributors( $pledge_id = 0 ) {
$contributors = array();
// Get POST'd submission, if it exists.
$submission = filter_input( INPUT_POST, 'pledge-contributors', FILTER_SANITIZE_STRING );
$submission = filter_input( INPUT_POST, 'org-pledge-contributors', FILTER_SANITIZE_STRING );
// Get existing pledge, if it exists.
$pledge = get_post( $pledge_id );

View file

@ -60,6 +60,12 @@ function get_pledge_meta_config( $context = '' ) {
'show_in_rest' => false,
'php_filter' => FILTER_VALIDATE_INT,
),
'org-pledge-contributors' => array(
'single' => true,
'sanitize_callback' => 'sanitize_text_field',
'show_in_rest' => false,
'php_filter' => FILTER_SANITIZE_STRING,
),
);
$generated = array(

View file

@ -15,8 +15,8 @@ namespace WordPressDotOrg\FiveForTheFuture\View;
<input
type="text"
id="5ftf-pledge-contributors"
name="pledge-contributors"
value="<?php echo esc_attr( $data['pledge-contributors'] ); ?>"
name="org-pledge-contributors"
value="<?php echo esc_attr( $data['org-pledge-contributors'] ); ?>"
required
aria-describedby="5ftf-pledge-contributors-help"
/>