You are here

function gathercontent_gathercontent_process_choice_checkbox_field in GatherContent 7.3

Parameters

EntityMetadataWrapper $node: Object of node.

string $local_field_name: Local field name.

string $gathercontent_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 gathercontent_gathercontent_process_choice_checkbox_field()
gathercontent_gathercontent_process_content_pane in ./gathercontent.module

File

./gathercontent.module, line 969

Code

function gathercontent_gathercontent_process_choice_checkbox_field(EntityMetadataWrapper &$node, $local_field_name, $gathercontent_field_name, $is_translatable = FALSE, $language = 'und', $options) {
  foreach ($node->{$local_field_name}
    ->getIterator() as $delta => $item) {
    $node->{$local_field_name}
      ->set(array(
      NULL,
    ));
  }
  $node
    ->save(TRUE);
  $selected_options = array();
  foreach ($options as $option) {
    if ($option->selected) {
      $selected_options[] = $option->name;
    }
    if ($is_translatable) {
      $node
        ->language($language)->{$local_field_name} = $selected_options;
    }
    else {
      $node->{$local_field_name} = $selected_options;
    }
  }
}