Drupal overriding existing option list values

Currently entityreference do not support filtering (via views like references). I have to filter the returned result of option lists manually via hook_form_alter.

$new_options = array(1 => 'One', 2 => 'Two', 3 => 'Three'); // while old values without filtering results in 10 items
$form['field_entityreference'][$lang]['#options'] = $new_options;

This works fine at front end, but when I viewed via dsm($form);, the old values are still there.

A couple of tries to no avail:

   if ($old_options = $form['field_entityreference'][$lang]['#options']) {
     foreach ($old_options as $key => $old_option) {

Or even unset($form['field_entityreference'][$lang]['#options']); With array_diff_key also the old options are still held there.

The front end is just fine, only new options shown, but I need to exclude the unneeded from the source, because rules always evaluates to true when they are not totally removed which is unexpected.

How do you remove lingering old values, so that only the new values are held even in the backend?

The helpful function is not there yet: http://drupal.org/node/1085704. Any hint would be very much appreciated. Thanks


Sorry to bother. This is a matter of dsm() placement. Actually all is good. The problem is dsm(); was always placed prior to any overrides, and drupal still read the old values. Placing dsm(); after the overrides displays the expected results, what a struggle :). Rules is another story.

Need Your Help

Supporting multiple resolutions in flash game

actionscript-3 flash resolution

I'm working on a little flash game that has a couple of GUI components. I'm having a bit of trouble coming up with a good design that can support a min spec of 768x1024 and a max spec of 1200 x 192...

SharePoint (MOSS 2007) successful forms authentication redirects to machine name

sharepoint forms-authentication

I have a SharePoint site extended for forms authentication. The Active Directory site is example.com and the forms authentication site is forms.example.com. When I type my (forms) username/passwo...

Error converting data type varchar to numeric when casting varchar(max) to decimal

tsql stored-procedures sql-server-2008-r2 varchar

I'm trying to sum values from two strings. In order to do that I'm casting the strings in to decimals, add them up and then cast it back to string for the output. Also using max to avoid duplication

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.