View source
<?php
function _cmis_browser_block_settings_path_form($delta, $value = '/') {
return array(
'#type' => 'textfield',
'#title' => t('Target document path @n', array(
'@n' => $delta + 1,
)),
'#default_value' => $value,
'#description' => t('The document path relative to the root of the repository.'),
'#autocomplete_path' => 'cmis/autocomplete',
'#size' => 60,
'#parents' => array(
'cmis_target_document_items',
$delta,
),
);
}
function cmis_browser_block_settings_more_items_js() {
$delta = count($_POST['cmis_target_document_items']);
$form_element = _cmis_browser_block_settings_path_form($delta);
drupal_alter('form', $form_element, array(), 'cmis_block_settings_more_items_js');
$form_state = array(
'submitted' => FALSE,
);
$form_build_id = $_POST['form_build_id'];
if (!($form = form_get_cache($form_build_id, $form_state))) {
exit;
}
$form['block_settings']['cmis_target_document_items'][] = $form_element;
form_set_cache($form_build_id, $form, $form_state);
$form += array(
'#post' => $_POST,
'#programmed' => FALSE,
);
$form = form_builder('block-admin-configure', $form, $form_state);
$items_form = $form['block_settings']['cmis_target_document_items'];
unset($items_form['#prefix'], $items_form['#suffix']);
$output = theme('status_messages') . drupal_render($items_form);
drupal_json(array(
'status' => TRUE,
'data' => $output,
));
}