Skip to:
Content

BuddyPress.org

Changeset 8653


Ignore:
Timestamp:
07/20/2014 08:10:31 PM (10 years ago)
Author:
djpaul
Message:

xProfile: fix datebox field validation.

If a validation error occurred when saving a profile field(s), the datebox field type wasn’t restoring the user-submitted value after the screen was reloaded. This was a regression introduced in BuddyPress 2.0 with the Profile Field Types rewrite.

Fixes #5690 (branch), props esroyo for initial patch

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.0/bp-xprofile/bp-xprofile-classes.php

    r8651 r8653  
    15481548     */
    15491549    public function edit_field_options_html( array $args = array() ) {
    1550         $options = $this->field_obj->get_children();
    1551         $date    = BP_XProfile_ProfileData::get_value_byid( $this->field_obj->id, $args['user_id'] );
     1550        $options    = $this->field_obj->get_children();
     1551        $date       = BP_XProfile_ProfileData::get_value_byid( $this->field_obj->id, $args['user_id'] );
     1552        $eng_months = array( 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December' );
    15521553
    15531554        $day   = 0;
     
    15801581
    15811582        if ( ! empty( $_POST['field_' . $this->field_obj->id . '_month'] ) ) {
    1582             $new_month = (int) $_POST['field_' . $this->field_obj->id . '_month'];
    1583             $month     = ( $month != $new_month ) ? $new_month : $month;
     1583            if ( in_array( $_POST['field_' . $this->field_obj->id . '_month'], $eng_months ) ) {
     1584                $new_month = $_POST['field_' . $this->field_obj->id . '_month'];
     1585            } else {
     1586                $new_month = $month;
     1587            }
     1588
     1589            $month = ( $month !== $new_month ) ? $new_month : $month;
    15841590        }
    15851591
    15861592        if ( ! empty( $_POST['field_' . $this->field_obj->id . '_year'] ) ) {
    1587             $new_year = date( 'j', (int) $_POST['field_' . $this->field_obj->id . '_year'] );
     1593            $new_year = (int) $_POST['field_' . $this->field_obj->id . '_year'];
    15881594            $year     = ( $year != $new_year ) ? $new_year : $year;
    15891595        }
     
    16001606
    16011607            case 'month':
    1602                 $eng_months = array( 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December' );
    1603 
    16041608                $months = array(
    16051609                    __( 'January', 'buddypress' ),
Note: See TracChangeset for help on using the changeset viewer.