You are here

function computed_field_field_settings_form_validate in Computed Field 7

#element_validate callback for computed_field_field_settings_form().

1 string reference to 'computed_field_field_settings_form_validate'
computed_field_field_settings_form in ./computed_field.module
Implements hook_field_settings_form().

File

./computed_field.module, line 273
Functionality for the computed field.

Code

function computed_field_field_settings_form_validate($element, &$form_state) {
  $settings = $form_state['values']['field']['settings'];
  if ($settings['store']) {
    if (empty($settings['database']['data_type'])) {
      form_set_error('field][settings][data_type', t('To store this field in the database, please specify a data type.'));
    }
    if (($settings['database']['data_type'] == 'text' || $settings['database']['data_type'] == 'varchar') && empty($settings['database']['data_length'])) {
      form_set_error('field][settings][database][data_length', t('To store this field in the database, please specify the data length.'));
    }
    if (($settings['database']['data_type'] == 'int' || $settings['database']['data_type'] == 'float') && (!empty($settings['database']['data_default']) && !is_numeric($settings['database']['data_default']))) {
      form_set_error('field][settings][database][data_default', t('Your default value should be numeric given your data type.'));
    }
  }
}