Form Submission
IceCreamYou - July 26, 2008 - 04:37
I'm working on a module that implements Facebook-style statuses for each user. (direct download - until I figure out CVS)
The module uses a textfield, and pressing the Save button is supposed to store whatever's in the textfield into the database--but it's not working. Any ideas why, or how to fix it? Thanks in advance--
Here's the relevant code:
<?php
//builds the status submission form
function _facebook_status_form() {
$form['name'] = array(
'#type' => 'textfield',
'#title' => 'Status',
'#size' => 30,
'#maxlength' => 256,
'#description' => 'Enter your status',
'#default_value' => 'is '
);
$form['submit'] = array('#type' => 'submit', '#value' => 'Save');
return $form;
}
//renders the status submission form; call this if you want to display it arbitrarily
function facebook_status_form_display() {
return drupal_get_form('_facebook_status_form');
}
//the submit function, tells Drupal what to do when the status is submitted
function _facebook_status_form_submit($form, &$form_state) {
db_query("UPDATE {users} SET status_fb = '%s' AND status_time = %d WHERE uid = %d", $form_values['name'], time(), $user->uid);
drupal_set_message('Your status has been saved.');
}
?>
I put the wrong URL for the
I put the wrong URL for the direct download.
http://www.icecreamyou.com/facebook_status.tar.gz
Ummmmm
status_fb and status_time are not fields in the user table. Have you added them? This is not good drupal style, use profile fields or check out the "data" field. Another option is a facebokk_status table in tandem with the user table using the api hook for add, update and delete.
Changing core makes upgrading a mare.
www.purpleoar.co.nz/scryptik - Javascript editor with syntax error checking
www.purpleoar.co.nz - Web development, Drupal consultancy
Never mind, I think this was
Never mind, I think this was solved in an issue in this module: http://drupal.org/node/287190