0
function custom_third_level_auto_suggest_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
$form['#after_build'] = 'custom_third_level_auto_suggest_widget_selection_afterbuild';

}

I need to pass $element across #after_build function, how I can implement it?

1

Most of callbacks like #after_build will received automatically 2 arguments: $elements and $form_state, like this :

my_callback_after_build($element, &$form_state){
//...
} 

So you simply have to push your var in the form_state var from where you add your callback :

function custom_third_level_auto_suggest_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
   $form['#after_build'] = 'custom_third_level_auto_suggest_widget_selection_afterbuild';
   $form_state['foo'] = 'bar';
}

And you'll get it in the form_state var of your callback like this:

function custom_third_level_auto_suggest_widget_selection_afterbuild($form, &$form_state){
   var_dump($form_state['foo']); //will print "bar"
} 

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.