I've created a custom CCK field of type Float and then using Node Import Module to import values.

Getting the error: "(field_name) cannot be longer than 10 characters but is currently 11 characters long"

Is there a way to override the maximum float length of 10 ? Maybe by altering the SQL table directly?

Only found http://drupal.org/node/312159, which did not mention a solution.

Thanks!

Comments

thinkling’s picture

I ran into this too.

For others who find this issue in the future:

The limitation is not in the database -- CCK stores floats as SQL floats. It's the number field's maxlength property on the node-edit form that is getting in the way.

If you need a permanent solution, you should be able to form-alter the node-edit form to set the #maxlength property higher.

Since I just needed to do a one-time data import, I made a temporary edit to number_process() in modules/cck/modules/number/number.module to set the maxlength higher.

Don't kill any kittens... I'll change it back to its pristine self.

brian_c’s picture

Setting #maxlength from hook_form_alter() doesn't work.

The reason being, the Number module actually sets #maxlength to the field's precision value (and if precision is absent, it uses a hard-coded value of 10).

From number_process() in number.module:

  '#maxlength' => isset($field['precision']) ? $field['precision'] : 10,


Thus, the solution is to actually set precision in the field's #field_info settings. So in hook_form_alter():

  $form['#field_info']['field_MYFIELDNAME']['precision'] = 20;

This is working for me.