add a field and set label to chinseses,then on manage fields table list ,the name is incorrect.
is not field_(label name) but field_ .
attachment is a picture for this.

CommentFileSizeAuthor
tt.BMP186.57 KBoscnet
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

oscnet’s picture

Category: bug » feature

content_admin.inc

function _content_admin_field_add_new_submit($form_id, $form_values) {
  // Find a valid, computer-friendly field name.

  $fields = _content_fields();

  $field_name = trim($form_values['label']);
  $field_name = drupal_strtolower($field_name);
  $field_name = str_replace(array(' ', '-'), '_', $field_name);
  $field_name = preg_replace('/[^a-z0-9_]/', '', $field_name); 
  $field_name = 'field_'. $field_name;
  $field_name = substr($field_name, 0, 31);

$field_name = preg_replace('/[^a-z0-9_]/', '', $field_name);
set field_name to use a-z0-9 only.
it is not a bug , so I set it as feature request.
it seems to important to me for theme the cck node type,it can make css more readable.

JonBob’s picture

Yes, this is important to address, but I'm not sure how. We use the name string in several internal places where only ASCII is accepted. How should we make the conversion from non-Latin scripts to something reasonable in ASCII? I really dislike having a field for entering the name; in Latin scripts the automatic name generation is a great timesaver and allows us to avoid a lot of tedious instructions about what characters are valid.

JonBob’s picture

Title: name are error when set fields label as a chineses word » Unfriendly names for fields with non-ASCII labels
Priority: Critical » Normal
oscnet’s picture

I had delete two lines in content_admin.inc:
$form_values['type_name'] = preg_replace('/[^a-z0-9_]/', '', $form_values['type_name']);
$field_name = preg_replace('/[^a-z0-9_]/', '', $field_name);

then test the cck , all had worked now.
JonBob had said We use the name string in several internal places where only ASCII is accepted.
now i am doubt. as I know php and mysql now all support uft8, so where are only ASCII is accepted ?
is there something I wrong?

JonBob’s picture

We'd need to verify that PHP, MySQL, and PostgreSQL support UTF-8 not just in strings, but in variable names, table names, column names... there might be more too, but at least those. And we have to check this for all versions we support.

oscnet’s picture

all I know current php support UTF-8 variable name , function name ,as I often use function name ,variable name as chinese, and mysql can use fields name as chinese no problem .
I not use PostgreSQL currently . so anyone know about it?
I also had tested .css file which contain uft8 class name, it worked and pass W3C CSS check.

KarenS’s picture

Status: Active » Fixed

A very old issue that is taken care of in later versions by having the user explicitly set the machine name.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.