I am using drupal 7. I need to add extra arguments to my ajax callback function. I have five fieldsets in my form, and in all of them same there are same elements, just their IDs are different. For example; group-1
, group-2
... I need to include that 1,2,3..
part in the callback function as arguments. Otherwise, it will be too complicated to build a logic to predict which fieldset element need to change.
For example, is such a an implementation possible?
function mymodule_form($form, $form_state) {
$group = 1;
// Some form elements...
$form['button'] = array(
'#type' => 'button',
'#ajax' => array(
'callback' => 'my_callback_function',
'wrapper' => 'my_target_area',
'arguments' => array($group1, ...) // Is such a thing possible or another way?
),
);
}
function my_callback_function($args, $form, $form_state) {
$arguments = $args;
return $form['my_target_area'];
}
This question as already been asked here. But I those answers don't fit my needs mentioned above. Thank you.