You are here

function gc_gc_process_choice_radio_field in GatherContent 8

Same name and namespace in other branches
  1. 8.3 gathercontent.module \gc_gc_process_choice_radio_field()

Parameters

EntityMetadataWrapper $node: Object of node.

string $local_field_name: Local field name.

string $gc_field_name: Name of field in GatherContent.

bool $is_translatable: Indicator if node is translatable.

string $language: Language of translation if applicable.

array $options: Array of options.

1 call to gc_gc_process_choice_radio_field()
gc_gc_process_content_pane in ./gathercontent.module

File

./gathercontent.module, line 464
Main module file for GatherContent module.

Code

function gc_gc_process_choice_radio_field(EntityMetadataWrapper &$node, $local_field_name, $gc_field_name, $is_translatable = FALSE, $language = 'und', $options) {
  foreach ($options as $option) {
    if ($option->selected) {
      if (isset($option->value)) {
        if ($is_translatable) {
          $node
            ->language($language)->{$local_field_name}
            ->set($option->value);
        }
        else {
          $node->{$local_field_name}
            ->set($option->value);
        }
      }
      else {
        if ($is_translatable) {
          $node
            ->language($language)->{$local_field_name}
            ->set($option->name);
        }
        else {
          $node->{$local_field_name}
            ->set($option->name);
        }
      }
    }
  }
}