You are here

public function FlexiformFormEntityFieldCollection::configForm in Flexiform 7

Get the Configuration Form.

Overrides FlexiformFormEntityBase::configForm

File

includes/form_entity/field_collection.form_entity.inc, line 67
Contains class for a basic entity getter.

Class

FlexiformFormEntityFieldCollection
Form entity to get a field collection item.

Code

public function configForm($form, &$form_state) {
  $form = parent::configForm($form, $form_state);
  $field = field_info_field($this->settings['bundle']);
  if ($field['cardinality'] != 1) {
    $options = array();
    $options['new'] = t('Always New Item');
    $i = 0;
    while ($i < 10) {
      if ($field['cardinality'] > 0 && $i >= $field['cardinality']) {
        break;
      }
      $options[$i] = $i + 1;
      ++$i;
    }
    $form['settings']['delta'] = array(
      '#title' => t('Delta'),
      '#type' => 'select',
      '#description' => t('Select which value of this field you want to use. If "Always New Item" is selected, a new item will be added unless there is no space for one, in which case no entity will be provided.'),
      '#options' => $options,
      '#default_value' => !empty($this->settings['delta']) ? $this->settings['delta'] : 0,
    );
  }
  $form['settings']['create'] = array(
    '#title' => t('Create if Empty'),
    '#description' => t('When ticked, if the field item is empty, a new collection will be created.'),
    '#type' => 'checkbox',
    '#default_value' => !empty($this->settings['create']),
  );
  return $form;
}