Certain elements do not yet have their#optionspopulated duringhook_form_alter. In such cases you won't be able to simply change the values from form alter, but will need to use after_build. In your form_alter:
<?php $form['#after_build'] = 'my_function'; ?>
And then:
<?php function my_function($form, &$form_state) { //modify data here! echo '<pre>'; print_r($form); echo '</pre>';exit(); } ?>
Comments
Starting off I felt like this
Starting off I felt like this was an easy endeavor. But I'm definitely struggling.
I'm seeing stuff about CCK being special. Stuff about "after_build." I wish there was a clear cut example of how to do this.
Argh.
You can try giving the same
You can try giving the same form item and give the form options which you want to change by declalring those options here
First of all, do this to see
First of all, do this to see what's currently available:
<?php
echo '<pre>';
print_r($form);
echo '</pre>';exit();
?>
Certain elements do not yet have their
#options
populated duringhook_form_alter
. In such cases you won't be able to simply change the values from form alter, but will need to use after_build. In your form_alter:<?php
$form['#after_build'] = 'my_function';
?>
And then:
<?php
function my_function($form, &$form_state) {
//modify data here!
echo '<pre>';
print_r($form);
echo '</pre>';exit();
}
?>
---
Yuriy Babenko | Senior Developer
http://yuriybabenko.com
来自 https://drupal.org/node/1068754