You are here

function feeds_tamper_math_form in Feeds Tamper 7

Same name and namespace in other branches
  1. 6 plugins/math.inc \feeds_tamper_math_form()
1 string reference to 'feeds_tamper_math_form'
math.inc in plugins/math.inc

File

plugins/math.inc, line 17

Code

function feeds_tamper_math_form($importer, $element_key, $settings) {
  $form = array();
  $form['operation'] = array(
    '#type' => 'select',
    '#title' => t('Operation'),
    '#description' => t('The operation to apply to the imported value.'),
    '#required' => TRUE,
    '#options' => array(
      'addition' => '+',
      'subtraction' => '-',
      'multiplication' => '*',
      'division' => '/',
    ),
    '#default_value' => isset($settings['operation']) ? $settings['operation'] : '',
  );
  $form['flip'] = array(
    '#type' => 'checkbox',
    '#title' => t('Flip'),
    '#description' => t('Normally, the feed item will be processed like feed-value / setting-value. This option switches the order so that it is setting-value / feed-value.'),
    '#states' => array(
      'visible' => array(
        ':input[name="settings[operation]"]' => array(
          array(
            'value' => 'subtraction',
          ),
          array(
            'value' => 'division',
          ),
        ),
      ),
    ),
    '#default_value' => isset($settings['flip']) ? $settings['flip'] : FALSE,
  );
  $form['value'] = array(
    '#type' => 'textfield',
    '#title' => t('Value'),
    '#required' => TRUE,
    '#description' => t('A numerical value.'),
    '#default_value' => isset($settings['value']) ? $settings['value'] : '',
  );
  $form['log'] = array(
    '#type' => 'checkbox',
    '#default_value' => !empty($settings['log']),
    '#title' => t('Log'),
    '#description' => t('Log to the Feed log and print a message when an invalid value is found.'),
  );
  return $form;
}