Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Work out the form stuff.
- function missionary_profiles_wall_form($form, &$form_state) {
- $title = drupal_get_title();
- $temp = node_add('missionary_update');
- //get the actual value of the missionary id.
- $arg = arg(2);
- //$form['#node_edit_form'] = TRUE;
- //$form['#attributes'] = $temp['#attributes'];
- //$form['#entity_type'] = 'node';
- //$form['#bundle'] = 'missionary_update';
- $form['nid'] = $temp['nid'];
- $form['vid'] = $temp['vid'];
- $form['uid'] = $temp['uid'];
- $form['created'] = $temp['created'];
- $form['language'] = $temp['language'];
- $form['changed'] = $temp['changed'];
- //$form['#node'] = $temp['#node'];
- $form['type'] = $temp['type'];
- $form['title'] = $temp['title'];
- $form['body'] = $temp['body'];
- //replace any hyphens with white space.
- $arg = str_replace("-", " ", $arg);
- $terms = taxonomy_get_term_by_name($arg);
- $termid = NULL;
- //for now we'll just use the first one - introdduce more useful checking later.
- //@todo: check vocabularies
- foreach($terms as $tid => $term) {
- $termid = $tid;
- break;
- }
- if($termid != NULL) {
- $form['field_missionary'] = array('#type' => 'hidden',
- '#value' => $termid,
- '#name' => 'field_missionary[und]',
- '#id' => 'edit-field-missionary-und');
- }
- $form['author'] = array('#type' => 'hidden');
- $form['status'] = array('#type' => 'hidden',
- '#value'=> $temp['additional_settings']['group']['#groups']['additional_settings'][2]['status']['#default_value'],
- '#name' => 'status',
- '#id' => 'edit-status',);
- unset($temp);
- //set the action to the right adress
- //$form['#action'] = '/blockstest/'.$_GET['q'];
- //#redirect overides the redirect thing in form state.
- //$form['#redirect'] = '/blockstest/'.$_GET['q'];
- $form['actions'] = array(
- '#type' => 'actions',
- 'submit'=> array(
- '#type' => 'submit',
- '#value' => t('Save'),
- ),
- '#id' => 'edit-actions',
- );
- //reset the title back to its original state
- drupal_set_title($title);
- //@todo - hide text format options when the setting is filtered html.
- return $form;
- }
- function missionary_profiles_wall_form_validate($form, &$form_state) {
- //validation stuff
- module_load_include('inc', 'node', 'node.pages');
- node_form_validate($form, $form_state);
- }
- function missionary_profiles_wall_form_submit($form, &$form_state) {
- //drupal_set_message(print_r($form['#node'],true) . '<br />' . print_r($form_state,true));
- module_load_include('inc', 'node', 'node.pages');
- node_form_submit($form, $form_state);
- }
- //Define blocks
- function missionary_profiles_block_info() {
- $blocks['wall_form'] = array(
- 'info' => t('Wall Update Form'),
- 'cache' => DRUPAL_CACHE_PER_PAGE,
- );
- return $blocks;
- }
- function missionary_profiles_block_view($delta = '') {
- module_load_include('inc', 'node', 'node.pages');
- switch ($delta) {
- case 'wall_form':
- return array(
- 'subject' => t('Add an Update'),
- 'content' => drupal_get_form('missionary_profiles_wall_form'),
- );
- break;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement