All pastes #229715 Raw Edit

Mine

public text v1 · immutable
#229715 ·published 2006-10-30 22:04 UTC
rendered paste body

This is the code I'm using in form_alter to add a text field that will get a user id. Since it doesn't seem like I can hook the field to a variable, there must be a way to access the field later in nodeapi.

$form['access']['ac1'] = array(
  '#type' => 'textfield',
  '#title' => t('Access ID -1, 0, or UID'),
  '#default_value' => $node->ac1,
  '#size' => 5,
  '#maxlength' => 128,
  '#required' => TRUE,
);

My nodeapi wants the result from above but I'm not sure how to get it (new to php, drupal etc)
case 'insert':
    case 'update':
         drupal_set_message( "storing ac1 as gid nodeapi " . $node->ac1 );

      // Clear out any existing grants for the node, and set new ones.
      db_query('DELETE FROM {node_access} WHERE nid = %d AND realm = \'ac1\'', $node->nid );

      // for testing node_grants, I am hardwiring in a uid (or -1 registered user only, 0 everyone)
      db_query('INSERT INTO {node_access} (nid, gid, realm, grant_view, grant_update,
        grant_delete) VALUES (%d, %d, \'ac1\', %d, %d, %d)', $node->nid, $node->ac1, 1, 0, 0);
      //}
      break;