: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
* @param int $field_id Field ID.
* @param array $field_submit Array of selected choice IDs.
* @param array $form_data Form data and settings.
public function format( $field_id, $field_submit, $form_data ) { // phpcs:ignore Generic.Metrics.CyclomaticComplexity.TooHigh, Generic.Metrics.NestingLevel.MaxExceeded
$field_submit = array_values( (array) $field_submit );
$field = $form_data['fields'][ $field_id ];
$name = sanitize_text_field( $field['label'] );
if ( ! empty( $field_submit ) ) {
foreach ( $field_submit as $choice_checked ) {
foreach ( $field['choices'] as $choice_id => $choice ) {
if ( (int) $choice_checked !== (int) $choice_id ) {
$value = (float) wpforms_sanitize_amount( $choice['value'] );
// Increase total amount.
$value = wpforms_format_amount( $value, true );
if ( ! empty( $choice['label'] ) ) {
$choice_label = sanitize_text_field( $choice['label'] );
$value = $choice_label . ' - ' . $value;
$choice_labels[] = $choice_label;
$choice_values[] = $value;
$choice_keys[] = $choice_id;
if ( ! empty( $choice_keys ) && ! empty( $field['choices_images'] ) ) {
foreach ( $choice_keys as $choice_key ) {
$images[] = ! empty( $field['choices'][ $choice_key ]['image'] ) ? esc_url_raw( $field['choices'][ $choice_key ]['image'] ) : '';
wpforms()->get( 'process' )->fields[ $field_id ] = [
'value' => implode( "\r\n", $choice_values ),
'value_choice' => implode( "\r\n", $choice_labels ),
'value_raw' => implode( ',', array_map( 'absint', $field_submit ) ),
'amount' => wpforms_format_amount( $amount ),
'currency' => wpforms_get_currency(),
'id' => absint( $field_id ),
'type' => sanitize_key( $this->type ),