This is my custom form with working add more and dummy delete button.
function mymodule_mycustom_form($form, $form_state){
$form['checkboxes_fieldset'] = array(
'#prefix' => '<div id="checkboxes-div">',
'#suffix' => '</div>',
'#type' => 'fieldset',
'#description' => t('This is where we get automatically generated textfield'),
'#tree' => TRUE,
);
$form['checkboxes_fieldset']['number'] = array(
'#type' => 'textfield',
'#title' => 'number',
);
// dummy delete button
$form['checkboxes_fieldset']['delete'] = array(
'#type' => 'submit',
'#value' => 'delete',
);
$form['add'] = array(
'#value' => t('add more?'),
'#type' => 'submit',
'#ajax' => array(
'callback' => 'mymodule_add_callback',
'wrapper' => 'checkboxes-div',
'method' => 'append',
),
);
return $form;
}
This is ajax callback for add more button
function mymodule_add_callback($form, $form_state) {
return $form['checkboxes_fieldset'];
}
Now i want a working delete. But dont know how?