2

Is there a way to get the default value in a cck field (in drupal 6)?When I set the default value,the nodes created after that, are having this default value.(in database also ,table name is content_type_contenttypemachine).

Initially I set the default value as '1000' and later changed it to "4000" but when am trying to get the value from the content type table its retrieving the first value as "1000" and not the recent value "4000".

Is fetching the last record is the only way to get the latest default value I have set?

Thanks in advance, cheers.

1 Answer 1

3

No need to go directly into the database for that, you can use the content_field_instance_read() function:

module_load_include('inc', 'content', 'includes/content.crud');
$definition = content_field_instance_read(array('field_name' => 'field_foo'));

// Your mileage may vary here, inspect $definition[0]['widget'] to see what you've got available.
$default = $definition[0]['widget']['default_value'][0]['value'];

If you're dead set on going into the database, the info is stored as a serialised PHP string in the widget_settings column of the content_node_field_instance table.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.