Configuration form settings I would like to create a settings page for a user which allows them to save the options of a list which is to be used in a custom form. The list is called marketing source and it is added to a form which gets submitted with plain text values to an external API.

I know in field config for select lists you can do this but I want to do it on a custom config page for that specific list.

Foe example I would have a textfield in the config that had values like this

1|google
2|magazine


Then I need to convert that into a seralised array and store with variable set.

Is there a function that does that already for the field form?

Cheers Dan
This is how I achieved what I wanted, rather than use key value pairs I just used an empty textfield and used one line for each option and then when retrieving the textfield for the form I used the following.

$raw_marketing_options = explode(PHP_EOL, variable_get('marketing_sources_sources'));


I then just used the variable directly in the form.

$form['Marketing_source__c'] = array(
  '#type' =&gt; 'select',
  '#title' =&gt; 'Marketing source',
  '#options' =&gt; $raw_marketing_options,
);


There may be a safer way to do it as I am not sure how secure variable_set() is when storing plain text but only the administrator will see the textarea anyway.

Cheers