public function SearchApiDenormalizedEntityField::configurationForm in Search API Grouping 7.2
Return the settings form for this processor.
Overrides SearchApiAbstractProcessor::configurationForm
File
- includes/
processor_denormalize_field.inc, line 23 - Processor for configuring the denormalization per index.
Class
- SearchApiDenormalizedEntityField
- Processor to configure and handle the denormalization per index.
Code
public function configurationForm() {
$form = parent::configurationForm();
$form['permutation_limit'] = array(
'#type' => 'fieldset',
'#collapsible' => TRUE,
'#collapsed' => FALSE,
'#title' => t('Permutation limits'),
'#description' => t('Defines how man permutations should be processed. Can become handy if you just want to have one item of a muti-value field. Leave empty for no limit.'),
'#weight' => 1,
);
$entity_type = $this->index
->datasource()
->getEntityType();
$entity_info = entity_get_info($this->index
->datasource()
->getEntityType());
$bundle_infos = field_info_instances($this->index
->datasource()
->getEntityType());
$options = array();
foreach ($form['fields']['#options'] as $field_name => $label) {
if (stristr($field_name, ':')) {
list($field_name, $property) = explode(':', $field_name, 2);
}
if ($field_info = field_info_field($field_name)) {
$instance = field_read_instance($entity_type, $field_name, reset($field_info['bundles'][$entity_type]));
if (!empty($field_info['cardinality']) && ($field_info['cardinality'] == FIELD_CARDINALITY_UNLIMITED || $field_info['cardinality'] > 1)) {
$options[$field_name] = $instance['label'] . ' (' . $field_name . ')';
$form['permutation_limit'][$field_name] = array(
'#type' => 'textfield',
'#title' => $instance['label'] . ' (' . $field_name . ')',
'#size' => 4,
'#maxlength' => 10,
'#states' => array(
'visible' => array(
':input[name$="[denormalization_field][' . $field_name . ']"]' => array(
'checked' => TRUE,
),
),
),
'#default_value' => !empty($this->options['permutation_limit'][$field_name]) ? $this->options['permutation_limit'][$field_name] : NULL,
);
}
}
}
$form['fields']['#options'] = $options;
// Re-use but modify the default form element.
$form['fields']['#type'] = 'checkboxes';
unset($form['fields']['#attributes']);
$form['denormalization_field'] = $form['fields'];
$form['fields']['#access'] = FALSE;
$form['denormalization_field'] = array(
'#title' => t('The field to use to denormalize the items to index.'),
'#description' => t('The field hast to be selected for indexing to use it for denormalization.'),
'#default_value' => isset($this->options['denormalization_field']) ? $this->options['denormalization_field'] : NULL,
) + $form['denormalization_field'];
return $form;
}