Browse Source

Excising hibernate. Custom submit in collection showing how to do multipart form data in drupal.

7.x-2.x
Daniel Lamb 10 years ago
parent
commit
a05aee2bcb
  1. 35
      islandora_collection/islandora_collection.module

35
islandora_collection/islandora_collection.module

@ -35,7 +35,40 @@ function islandora_collection_node_info() {
* Implements hook_form().
*/
function islandora_collection_form($node, array &$form_state) {
return node_content_form($node, $form_state);
$form = node_content_form($node, $form_state);
$form['title']['#weight'] = -10;
$form['obj'] = array(
'#name' => 'obj',
'#type' => 'file',
'#title' => t('Image'),
'#description' => t('This file will be set as the "obj" pcdm:File for this object.'),
'#weight' => -5,
);
return $form;
}
function islandora_collection_form_node_form_alter(&$form, &$form_state) {
$form['actions']['submit']['#submit'][0] = 'islandora_collection_node_form_submit';
}
function islandora_collection_node_form_submit($form, &$form_state) {
//dsm($_SERVER);
//dsm($_POST);
//dsm($_FILES);
//dsm($form);
//dsm($form_state);
$url_front = "http://localhost:8080/islandora-services/rest/collection";
$options['method'] = 'POST';
$options['data'] = array(
'node' => json_encode($form['#node']),
'files' => array(
'obj' => $_FILES['obj']['tmp_name'],
),
);
httprl_request($url_front, $options);
$request = httprl_send_request();
//echo httprl_pr($request);
dsm("IN THE SUBMIT");
}
/**

Loading…
Cancel
Save