2

I do a form alter on a node form and make some callbacks which restrict value lists in a < select > element, which is a entity reference. When the triggering element is changed, I want to load the node forms default value just like it is in the beginning of the form process. I remember there was an api function to do that. Someone nows it?

5

field_get_default_value - Helper function to get the default value for a field on an entity.
Usage:

<?php
  $field = field_info_field('YOURFIELDNAME');
  $instance = field_info_instance('node', 'YOURFIELDNAME', 'YOURNODETYPE');
  $defvalue = field_get_default_value('node', $node, $field, $instance, $node->language);
  print_r($defvalue); // Here structure, like $defvalue[0]['value']
?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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