Skip to:
Content

BuddyPress.org

Changeset 8652


Ignore:
Timestamp:
07/20/2014 08:05:05 PM (9 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 (trunk), props esroyo for initial patch

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-xprofile/bp-xprofile-classes.php

    r8650 r8652  
    15611561    public function edit_field_options_html( array $args = array() ) {
    15621562
    1563         $date  = BP_XProfile_ProfileData::get_value_byid( $this->field_obj->id, $args['user_id'] );
    1564         $day   = 0;
    1565         $month = 0;
    1566         $year  = 0;
    1567         $html  = '';
     1563        $date       = BP_XProfile_ProfileData::get_value_byid( $this->field_obj->id, $args['user_id'] );
     1564        $day        = 0;
     1565        $month      = 0;
     1566        $year       = 0;
     1567        $html       = '';
     1568        $eng_months = array( 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December' );
    15681569
    15691570        // Set day, month, year defaults
     
    15921593
    15931594        if ( ! empty( $_POST['field_' . $this->field_obj->id . '_month'] ) ) {
    1594             $new_month = (int) $_POST['field_' . $this->field_obj->id . '_month'];
    1595             $month     = ( $month != $new_month ) ? $new_month : $month;
     1595            if ( in_array( $_POST['field_' . $this->field_obj->id . '_month'], $eng_months ) ) {
     1596                $new_month = $_POST['field_' . $this->field_obj->id . '_month'];
     1597            } else {
     1598                $new_month = $month;
     1599            }
     1600
     1601            $month = ( $month !== $new_month ) ? $new_month : $month;
    15961602        }
    15971603
    15981604        if ( ! empty( $_POST['field_' . $this->field_obj->id . '_year'] ) ) {
    1599             $new_year = date( 'j', (int) $_POST['field_' . $this->field_obj->id . '_year'] );
     1605            $new_year = (int) $_POST['field_' . $this->field_obj->id . '_year'];
    16001606            $year     = ( $year != $new_year ) ? $new_year : $year;
    16011607        }
     
    16121618
    16131619            case 'month':
    1614                 $eng_months = array( 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December' );
    1615 
    16161620                $months = array(
    16171621                    __( 'January',   'buddypress' ),
Note: See TracChangeset for help on using the changeset viewer.