function gc_gc_process_choice_checkbox_field in GatherContent 8
Same name and namespace in other branches
- 8.3 gathercontent.module \gc_gc_process_choice_checkbox_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_checkbox_field()
File
- ./
gathercontent.module, line 431 - Main module file for GatherContent module.
Code
function gc_gc_process_choice_checkbox_field(EntityMetadataWrapper &$node, $local_field_name, $gc_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;
}
}
}