# give/4.18.0/src/DonationForms/resources/app/utilities/getDefaultValuesFromSections.ts

GiveWP – Donation Plugin and Fundraising Platform, version 4.18.0. 27 lines.

- Page: https://pluginprobe.com/plugins/give/4.18.0/code/src/DonationForms/resources/app/utilities/getDefaultValuesFromSections.ts
- Raw: https://pluginprobe.com/plugins/give/4.18.0/raw/src/DonationForms/resources/app/utilities/getDefaultValuesFromSections.ts
- Modified: 2023-10-16T17:55:46+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/give/4.18.0/code/src/DonationForms/resources/app/utilities/getDefaultValuesFromSections.ts#L10-L20`.

```typescript
/**
 * Returns default values from an array of field collection objects
 *
 * @since 3.0.0
 *
 * @param sections
 * @return {*}
 */
import {Section} from '@givewp/forms/types';
import {reduceFields} from './groups';

export default function getDefaultValuesFromSections(sections: Section[]) {
    return reduceFields(
        sections,
        (values, field) => {
            const defaultValue = field.defaultValue;

            if (defaultValue !== null && defaultValue !== '') {
                values[field.name] = defaultValue;
            }

            return values;
        },
        {}
    );
}

```
