I'm working to create a "Save as Draft" button that is supposed to change the value of the Workflow form element when it submits. For some reason, the value is not getting changed. Here's the validate function in my module:

function draft_project_validate($form, &$form_state) {
  // Set the node to be draft or review depending on which button was
  // clicked.
  if ($form_state['triggering_element']['#value'] == $form['actions']['submit_draft']['#value']) {
    $element['#parents'] = array('workflow','Project Status');
    form_set_value($element, '2', $form_state);
    
  }
  elseif ($form_state['triggering_element']['#value'] == $form['actions']['submit']['#value']) {
    $element['#parents'] = array('workflow','Project Status');
    form_set_value($element, '3', $form_state);
    
  }
  
}

I know that the appropriate clauses are getting triggered properly, but for some reason the value is not getting set. For example, if I purposely submit a node that is missing required information, the Project Status form element remains whatever it was set to before clicking either "Submit" or "Save as Draft", as if the form_set_value is having no effect. Has anyone else tried to do something like this, and is there something I'm missing?

Comments

shendric’s picture

For others who might have had this issue, it turns out that I was able to solve this issue by not only using form_set_value, but also setting the actual form values for each radio button to the new status, in order for the radio buttons to reflect the appropriate value.

Bastlynn’s picture

Status: Active » Closed (works as designed)

Yeah, radio buttons are kinda twitchy that was in the Form API. Since this is taken care of, and came down to radio button misbehavior, I'm going to go ahead and close this one out.