diff options
author | Dries Buytaert <dries@buytaert.net> | 2009-09-07 15:50:52 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2009-09-07 15:50:52 +0000 |
commit | 157f6ee03005153cfd43f4952acf512734381968 (patch) | |
tree | 2e2e6fa87fc02edc69b6de7a97f9316cbb337834 /modules/field/field.crud.inc | |
parent | 1d2db443ae62f72d2cea589370473cf16f406394 (diff) | |
download | brdo-157f6ee03005153cfd43f4952acf512734381968.tar.gz brdo-157f6ee03005153cfd43f4952acf512734381968.tar.bz2 |
- Patch #372330 by fgm: improved error messages to improve usability.
Diffstat (limited to 'modules/field/field.crud.inc')
-rw-r--r-- | modules/field/field.crud.inc | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/modules/field/field.crud.inc b/modules/field/field.crud.inc index cae2ecdf5..2ce0998ce 100644 --- a/modules/field/field.crud.inc +++ b/modules/field/field.crud.inc @@ -231,10 +231,12 @@ function field_create_field($field) { // Ensure the field name is unique over active and disabled fields. // We do not care about deleted fields. - // TODO : do we want specific messages when clashing with a disabled or inactive field ? $prior_field = field_read_field($field['field_name'], array('include_inactive' => TRUE)); if (!empty($prior_field)) { - throw new FieldException(t('Attempt to create field name %name which already exists.', array('%name' => $field['field_name']))); + $message = $prior_field['active']? + t('Attempt to create field name %name which already exists and is active.', array('%name' => $field['field_name'])): + t('Attempt to create field name %name which already exists, although it is inactive.', array('%name' => $field['field_name'])); + throw new FieldException($message); } $field += array( @@ -447,10 +449,12 @@ function field_create_instance($instance) { // Problem : this would mean that a UI module cannot update an instance with a disabled formatter. // Ensure the field instance is unique. - // TODO : do we want specific messages when clashing with a disabled or inactive instance ? $prior_instance = field_read_instance($instance['field_name'], $instance['bundle'], array('include_inactive' => TRUE)); if (!empty($prior_instance)) { - throw new FieldException(t('Attempt to create a field instance %field_name,%bundle which already exists.', array('%field_name' => $instance['field_name'], '%bundle' => $instance['bundle']))); + $message = $prior_instance['widget']['active']? + t('Attempt to create a field instance %field_name,%bundle which already exists and is active.', array('%field_name' => $instance['field_name'], '%bundle' => $instance['bundle'])): + t('Attempt to create a field instance %field_name,%bundle which already exists, although inactive.', array('%field_name' => $instance['field_name'], '%bundle' => $instance['bundle'])); + throw new FieldException($message); } _field_write_instance($instance); |