Skip to content

Instantly share code, notes, and snippets.

Created March 28, 2010 23:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/347113 to your computer and use it in GitHub Desktop.
Save anonymous/347113 to your computer and use it in GitHub Desktop.
case 'selectbox':
if ( 'multiselectbox' != $field->type )
$html .= '<option value="">--------</option>';
for ( $k = 0; $k < count($options); $k++ ) {
$option_value = BP_XProfile_ProfileData::get_value_byid($options[$k]->parent_id);
/* Check for updated posted values, but errors preventing them from being saved first time */
if ( isset( $_POST['field_' . $field->id] ) && $option_value != $_POST['field_' . $field->id] ) {
if ( !empty( $_POST['field_' . $field->id] ) )
$option_value = $_POST['field_' . $field->id];
}
if ( $option_value == $options[$k]->name || $options[$k]->is_default_option ) {
$selected = ' selected="selected"';
} else {
$selected = '';
}
$html .= apply_filters( 'bp_get_the_profile_field_options_select', '<option' . $selected . ' value="' . attribute_escape( $options[$k]->name ) . '">' . attribute_escape( $options[$k]->name ) . '</option>', $options[$k] );
}
break;
case 'multiselectbox':
$option_values = BP_XProfile_ProfileData::get_value_byid($options[0]->parent_id);
/* Check for updated posted values, but errors preventing them from being saved first time */
if ( isset( $_POST['field_' . $field->id] ) && $option_values != maybe_serialize( $_POST['field_' . $field->id] ) ) {
if ( !empty( $_POST['field_' . $field->id] ) )
$option_values = $_POST['field_' . $field->id];
}
$option_values = maybe_unserialize($option_values);
for ( $k = 0; $k < count($options); $k++ ) {
for ( $j = 0; $j < count($option_values); $j++ ) {
if ( $option_values[$j] == $options[$k]->name || @in_array( $options[$k]->name, $value ) || $options[$k]->is_default_option ) {
$selected = ' selected="selected"';
break;
}
}
$html .= apply_filters( 'bp_get_the_profile_field_options_checkbox', '<option' . $selected . ' value="' . attribute_escape( $options[$k]->name ) . '"> ' . attribute_escape( $options[$k]->name ) . '</option>', $options[$k] );
$selected = '';
}
break;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment