Tell me more ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

I have created a select list for Profile2 account in Drupal 7. In the allowed values list I have added some value. Now what I would like to do is programmatically update the values in that list (add, delete or update). I don't want to use form_alter as I want these updates committed to the database. My problem is I can't seem to find where these values are stored in the database or how to pull those values from Profile2, update them and then save them.

I have Googled high and low on this particular issue and can't find an answer on how to do this. I hope someone can help me out.

Thanks.

share|improve this question

1 Answer

up vote 3 down vote accepted

Something along the lines of...

// Get the field info
$info = field_info_field('field_some_field');

// Get a reference to the values
$values = &$info['settings']['allowed_values'];

// Manipulate the values in some way, e.g.
$values['new_value'] = 'New Value';

// Save the field
field_update_field($info);
share|improve this answer
Thanks that is what I was looking for and works great! – user5013 Nov 9 '12 at 19:27
No probs, glad it helped. Hope you don't mind, I edited the question title so it has a better chance of coming up when other people are searching for the same issue – Clive Nov 9 '12 at 19:29

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.