I have a form with checkboxes that are calling ajax callback on checked. This ajax callback is appending another inputs:
$form['expertise']['op-cat-'.$op_cat['id']]['op-'.$op['id']]['checked'] = array(
'#type' => 'checkbox',
'#title' => $op['name'],
'#default_value' => isset($usr['user_scope']['tid'][$op['id']]) ? 1 : 0,
'#ajax' => array(
'callback' => 'activit_full_profile_expertise_ajax',
'wrapper' => 'expertise-div',
)
);
Ajax callback:
function activit_full_profile_expertise_ajax($form, &$state) {
$commands = array();
$commands[] = ajax_command_html('#expertise-div', render($form['expertise']));
$commands[] = array('command' => 'reinitializeTooltipster');
return array('#type' => 'ajax', '#commands' => $commands);
}
In form is also an another managed file input:
$form['image'] = array(
'#type' => 'managed_file',
'#title' => t('Profilová fotografia <span>(nepovinné)</span>'),
'#default_value' => isset($usr['picture']->fid) ? $usr['picture']->fid : 0,
'#upload_validators' => array('file_validate_extensions' => array('gif png jpg jpeg')),
'#upload_location' => 'public://user_images/'
);
Everything works fine if image field is not used after checkbox. If checkbox is used before image upload, it brings another input fields, but they are not present in $state['values']
in form validate & submit function (only original checkbox is present). They are not present in validate & submit function called by ajax of this image upload input, therefore they are not present in final validate & submit functions on form submit.
I have another custom ajax callbacks in form, but the appended input values are allways present. Is this a Drupal bug or am I missing something?