function mathfield_field_settings_form in Math Field 7
Implements hook_field_settings_form().
File
- ./
mathfield.module, line 37 - Adds a dynamic math expression field.
Code
function mathfield_field_settings_form($field, $instance, $has_data) {
$settings = $field['settings'];
$form['expression'] = array(
'#type' => 'textarea',
'#title' => t('Math Expression'),
'#description' => t("Enter mathematical expressions such as 2 + 2 or sqrt(5). You may assign variables and create mathematical functions and evaluate them. Use ';' to separate these. For example: f(x) = x + 2; f(2)."),
'#default_value' => $settings['expression'],
);
$form['field_dependencies'] = array(
'#type' => 'value',
'#value' => $settings['field_dependencies'],
'#element_validate' => array(
'mathfield_validate_expression',
),
);
$form['decimal_separator'] = array(
'#type' => 'select',
'#title' => t('Decimal marker'),
'#options' => array(
'.' => t('Decimal point'),
',' => t('Comma'),
),
'#default_value' => $settings['decimal_separator'],
'#description' => t('The character to mark the decimal point.'),
);
$form['precision'] = array(
'#type' => 'select',
'#title' => t('Precision'),
'#options' => drupal_map_assoc(range(10, 32)),
'#default_value' => $settings['precision'],
'#description' => t('The total number of digits to store in the database, including those to the right of the decimal.'),
'#disabled' => $has_data,
);
$form['scale'] = array(
'#type' => 'select',
'#title' => t('Scale'),
'#options' => drupal_map_assoc(range(0, 10)),
'#default_value' => $settings['scale'],
'#description' => t('The number of digits to the right of the decimal.'),
'#disabled' => $has_data,
);
return $form;
}