Hey guys love the module. Could you please clear this up for me.
I am using hook_form_alter to add a default value to the reference field. It is showing in the array when i run
dpm($form);
See attached image
But the field remains with value - none -
My Code is as follows
function soul_form_alter(&$form, &$form_state, $form_id) {
if($form_id == 'action_node_form') {
$form['field_client']['und']['#default_value'] = array(1 => 'Test Client');
}
}
I have also tried it as
function soul_form_alter(&$form, &$form_state, $form_id) {
if($form_id == 'action_node_form') {
$form['field_client']['und']['#default_value'] = array($clientid => $clientname);
}
}
I was just wondering if it is possible to set a default value or if the module overrides it some how. If so is there a way around this.
Thanks for taking the time to read this.
Gary
Comments
Comment #1
joachim commentedAre you sure that's to do with this module's work -- have you tried disabling it?
IIRC, FieldAPI does a lot of its widget building in an #after_build callback, so hook_form_alter() won't get to see everything.
Comment #2
ghaddon commentedIt only wanted the entity id so this works
Comment #3
ghaddon commentedComment #4
brunorios1 commentedI´m having the same problem.I have this scenario (fresh install):
Department (Vocabulary)
Category (Vocabulary)
- Department (Field - Term reference to Department Vocabulary)
Product (Node)
- Department (Field - Term reference to Department Vocabulary)
- Category (Field - Term reference to Category Vocabulary - Options limited according to matching Department field values)
I changed the default value of Department using a custom module:
But the Category field is not limited on the page load:
http://i.imgur.com/qnKcr1z.png
It only works if I select another value on the Department field and select Department One again:
http://i.imgur.com/jhoGfJi.png
Thank you.
--
EDIT:
Actually, it works. Sorry about that.
Comment #5
brunorios1 commentedComment #6
jomarocas commentedThis is still wrong, i want to put the default value in category, but no working because depent of the department, i need to put default value in category with depent of department