---
title: "Populate Drop Down, Radio Buttons or Checkboxes with a CSV File - Convert Forms"
description: "You can easily popoulate your Drop Down, Radio Buttons as well as Checkboxes fields using a CSV file without having to enter each choice one by one by"
url: "https://www.tassos.gr/docs/convert-forms/functionality/populate-drop-down-radio-buttons-or-checkboxes-with-a-csv-file"
date: "2026-04-29T06:44:43+00:00"
language: "en-GB"
---

[ Home ](https://www.tassos.gr/index.php?option=com_content&view=category&layout=blog&id=24&Itemid=1088) / [ Convert Forms ](https://www.tassos.gr/index.php?option=com_content&view=category&id=43) / [ Functionality ](https://www.tassos.gr/index.php?option=com_content&view=category&id=60)

#  Populate Drop Down, Radio Buttons or Checkboxes with a CSV File

You can easily popoulate your Drop Down, Radio Buttons as well as Checkboxes fields using a CSV file without having to enter each choice one by one by yourself. This will help you save a lot of time if you have a large list of options. Below you can find a step by step tutorial on how to populate your fields.

## [1. What is a CSV file?](#create_csv)

CSV stands for comma separated value. A CSV or .csv file is a delimited text file that uses a comma to separate values. CSV files can be imported to and exported from programs that store data in tables, such as Microsoft Excel or Google Sheets. For example, let's say you had a spreadsheet containing the following data.

 | Label | Value | Calc Value |
|---|---|---|
| Mars | 5 | 500 |
| Jupiter | 50 | 250 |
| Earth | 15 | 60 |
| Moon | 35 | 380 |

The above data could be represented in a CSV-formatted file as follows:

 ```
Mars,5,500

Jupiter,50,250

Earth,15,60

Moon,35,380

```

Here, the fields of data in each row are delimited with a comma and individual rows are separated by a newline.

## [2. Create the CSV file](#create_csv)

First of all, you need to create a CSV file if you have not yet created one. This CSV file needs to be comma-separated and have the following format:

 | Label,Value,Calculation Value |
|---|

**Label**: Label of the item

**Value**: Value of the item

**Calculation Value**: Value used in the calculations of the item

*Value* and *Calculation Value* are optional and may not be included in the CSV.

Example containing only labels:

 ```
Option 1

Option 2

Option 3

```

Example containing labels and values:

 ```
Option 1,5

Option 2,10

Option 3,15

```

Example containing labels, values and calculation values:

 ```
Option 1,5,50

Option 2,10,100

Option 3,15,150

```

## [3. Upload CSV file to your server](#upload_csv)

After you have created your CSV file, its now ready to be uploaded to your server. Log into your administrator panel &gt; Content &gt; Media &gt; upload your CSV file or use a FTP software of your choice to upload the CSV file to your desired location.

## [4. Create your field](#create_field)

This field can either be a dropdown, radio buttons or checkboxes.

One you have created your field, set the Field Name.

## [4. Add the PHP Snippet](#add_php_snippet)

Copy the following PHP snippet and paste it in your form &gt; Behavior &gt; PHP Scripts &gt; Form Prepare

 ```
// Enter the Field Name of the field you created above
$choices_field_name = 'dropdown';

// Enter path to CSV file starting from your Joomla root directory
$file_path = 'media/csv/cf_data.csv';

// Do not edit below
$file_path = JPATH_SITE . '/' . ltrim($file_path, '/');
if (!is_file(\Joomla\Filesystem\Path::clean($file_path)))
{
	return;
}

if (!$contents = file_get_contents($file_path))
{
	return;
}

// remove previous choices
unset($form['fields'][$choices_field_name]['choices']['choices']);

// add CSV choices
foreach(preg_split("/((\r?\n)|(\r\n?))/", $contents) as $line)
{
	$data = explode(',', $line);

	$label = isset($data[0]) ? $data[0] : false;
	if (!$label)
	{
		continue;
	}

	$form['fields'][$choices_field_name]['choices']['choices'][] = [
		'label' => $label,
		'value' => isset($data[1]) ? $data[1] : '',
		'calc-value' => isset($data[2]) ? $data[2] : ''
	];
}
```

Finally, you need to set which Field will be populated as well as define the CSV file path. To do so, in the above code you copy/pasted, set the Field Name as well as the path to the CSV file in the following variables:

 ```
// Enter the Field Name of the field you created above
$choices_field_name = 'dropdown';

// Enter path to CSV file starting from your Joomla root directory
$file_path = 'media/csv/cf_data.csv';
```

Note: *$file\_path* needs to start from the root directory of your Joomla installation.

 Last updated on Feb 10th 2026 19:02

## Schema

```json
{
    "@context": "https://schema.org",
    "@type": "BreadcrumbList",
    "itemListElement": [
        {
            "@type": "ListItem",
            "position": 1,
            "name": "Home",
            "item": "https://www.tassos.gr"
        },
        {
            "@type": "ListItem",
            "position": 2,
            "name": "Home",
            "item": "https://www.tassos.gr/docs"
        },
        {
            "@type": "ListItem",
            "position": 3,
            "name": "Convert Forms",
            "item": "https://www.tassos.gr/docs/convert-forms"
        },
        {
            "@type": "ListItem",
            "position": 4,
            "name": "Functionality",
            "item": "https://www.tassos.gr/docs/convert-forms/functionality"
        },
        {
            "@type": "ListItem",
            "position": 5,
            "name": "Populate Drop Down, Radio Buttons or Checkboxes with a CSV File",
            "item": "https://www.tassos.gr/docs/convert-forms/functionality/populate-drop-down-radio-buttons-or-checkboxes-with-a-csv-file"
        }
    ]
}
```

```json
{
    "@context": "https://schema.org",
    "@type": "Article",
    "mainEntityOfPage": {
        "@type": "WebPage",
        "@id": "https://www.tassos.gr/docs/convert-forms/functionality/populate-drop-down-radio-buttons-or-checkboxes-with-a-csv-file"
    },
    "headline": "Populate Drop Down, Radio Buttons or Checkboxes with a CSV File",
    "image": {
        "@type": "ImageObject",
        "url": "https://www.tassos.gr/"
    },
    "publisher": {
        "@type": "Organization",
        "name": "Tassos",
        "logo": {
            "@type": "ImageObject",
            "url": "https://www.tassos.gr/https://www.tassos.gr/media/brand/logo-text.png"
        }
    },
    "author": {
        "@type": "Person",
        "name": "Tassos Marinos",
        "url": "https://www.tassos.gr/docs/convert-forms/functionality/populate-drop-down-radio-buttons-or-checkboxes-with-a-csv-file"
    },
    "datePublished": "2020-11-09T10:15:04+02:00",
    "dateCreated": "2020-11-13T11:15:59+02:00",
    "dateModified": "2026-02-10T19:02:40+02:00"
}
```
