Hello

I am trying to build a url query string using node objects when a alter_form submit button is pressed. To do this I use a function called elertz_form_submit however I can't seem to read any of the node objects. I found out how to do it the form_alter by doing:

$node = $form['#node'];
$title= $node->title;

This does not work with my submit function.

Am I doing something very stupid?

Thank you

David

function elertz_form_alter($formid, &$form) {
$form['#submit']['elertz_form_submit'] = array();

return;
      }

function elertz_form_submit($form_id, $form_values) {

$elertz_update_url = variable_get('elertz_update_url',"");
$webmaster_id = variable_get('elertz_webmaster_id',"");
$elertz_fire_password = variable_get('elertz_fire_password',"");
$elertz_notification_description = urlencode(variable_get('elertz_notification_description',""));
$schema_id = variable_get('elertz_schema_id',"");
$server_name = $_SERVER["SERVER_NAME"];
$url = $server_name.'?q=node/'.$node->uid;
$node = $form_values['#node'];
$title= urlencode($node->title);
$elertzfirestring = $elertz_update_url
                    .'?webmaster_id='
                    .$webmaster_id
                    .'&password='
                    .$elertz_fire_password
                    .'&url='
                    .$url
                     .'&schema_id='
                    .$schema_id
                    .'&sms_txt='
                    .$elertz_notification_description
                    .'&ampnotification_description='
                    .$elertz_notification_description
                    .'&title='
                    .$title
                    .'&where=title';

trigger_error($elertzfirestring);
file_get_contents($elertzfirestring);
  return;
}

[ Edited to add <code> and </code> tags: nevets ]

Comments

nevets’s picture

The nodepai hook already provides methods for acting on nodes when they are submitted (among other things). Since the nodeapi hook has $node as a parameter this seems like it might provide an easer approach to what you are attempting to do.

stclaird’s picture

thank you

stclaird’s picture

Hello I think i am on the right lines but not quite as when i am editing a node (story/page) and then submit the form returns 'Your has been created.' but nothing has actually happened. So i have broken my form it would appear!

Am i missing something obvious? I have been trawling the site for so long my eyes are burning!

Thank you

David

function elertz_nodeapi(&$node, $op, $arg = 0) {
  switch ($op) {
  case 'submit':
$elertz_update_url = variable_get('elertz_update_url',"");
$webmaster_id = variable_get('elertz_webmaster_id',"");
$elertz_fire_password = variable_get('elertz_fire_password',"");
$elertz_notification_description = urlencode(variable_get('elertz_notification_description',""));
$schema_id = variable_get('elertz_schema_id',"");
$server_name = $_SERVER["SERVER_NAME"];
$url = $server_name.'?q=node/'.$node->uid;
$node = $form_['#node'];
$title= urlencode($node->title);
$elertzfirestring = $elertz_update_url
                    .'?webmaster_id='
                    .$webmaster_id
                    .'&password='
                    .$elertz_fire_password
                    .'&url='
                    .$url
                     .'&schema_id='
                    .$schema_id
                    .'&sms_txt='
                    .$elertz_notification_description
                    .'&ampnotification_description='
                    .$elertz_notification_description
                    .'&title='
                    .$title
                    .'&where=title';

trigger_error($elertzfirestring);
file_get_contents($elertzfirestring);}

}
stclaird’s picture

using update seems to have fixed it