Skip to main content
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Corrected spelling.
Source Link
Pierre.Vriens
  • 36k
  • 40
  • 50
  • 182

I currently have a custom module which calls a submit custom validation function. I am trying to update a value after the validation is run. Basically, if a value is present, update a field to say "Yes".

function sitefuncs_form_alter(&$form, &$form_state, $form_id){
 
if( $form_id == 'stage_2_node_form') {
   $form['actions']['submit']['#submit'][] = 'sitefuncs_custom_submit';
}
 
} // end hook_form_alter()
 
function sitefuncs_custom_submit($form, &$form_state) {
 
        $banned = array(
        'better cures',
        'better nhs',
        'because it',
        'so what'
        );
 
  if (in_array($form_state['values']['field_stage_two_question_one']['und'][0]['value'], $banned)) { // if a banned word is the value of the input
 
$form_state['values']['field_stage_complete_text']['und'][0]['value'] = "No"; // set the value of the text input to No
 
} else {
 
$form_state['values']['field_stage_complete_text']['und'][0]['value'] = "Yes";
 
$messages = drupal_get_messages('status');
drupal_set_message(t('Your changes have been saved.'));
 
}
 
}

If anyone has any idea why the $form_state isn't updating the fields after I save the node, any help would be great!

Thanks.

I currently have a custom module which calls a submit custom validation function. I am trying to update a value after the validation is run. Basically, if a value is present, update a field to say "Yes".

function sitefuncs_form_alter(&$form, &$form_state, $form_id){
 
if( $form_id == 'stage_2_node_form') {
   $form['actions']['submit']['#submit'][] = 'sitefuncs_custom_submit';
}
 
} // end hook_form_alter()
 
function sitefuncs_custom_submit($form, &$form_state) {
 
        $banned = array(
        'better cures',
        'better nhs',
        'because it',
        'so what'
        );
 
  if (in_array($form_state['values']['field_stage_two_question_one']['und'][0]['value'], $banned)) { // if a banned word is the value of the input
 
$form_state['values']['field_stage_complete_text']['und'][0]['value'] = "No"; // set the value of the text input to No
 
} else {
 
$form_state['values']['field_stage_complete_text']['und'][0]['value'] = "Yes";
 
$messages = drupal_get_messages('status');
drupal_set_message(t('Your changes have been saved.'));
 
}
 
}

If anyone has any idea why the $form_state isn't updating the fields after I save the node, any help would be great!

Thanks.

I currently have a custom module which calls a submit custom validation function. I am trying to update a value after the validation is run. Basically, if a value is present, update a field to say "Yes".

function sitefuncs_form_alter(&$form, &$form_state, $form_id){
 
if( $form_id == 'stage_2_node_form') {
   $form['actions']['submit']['#submit'][] = 'sitefuncs_custom_submit';
}
 
} // end hook_form_alter()
 
function sitefuncs_custom_submit($form, &$form_state) {
 
        $banned = array(
        'better cures',
        'better nhs',
        'because it',
        'so what'
        );
 
  if (in_array($form_state['values']['field_stage_two_question_one']['und'][0]['value'], $banned)) { // if a banned word is the value of the input
 
$form_state['values']['field_stage_complete_text']['und'][0]['value'] = "No"; // set the value of the text input to No
 
} else {
 
$form_state['values']['field_stage_complete_text']['und'][0]['value'] = "Yes";
 
$messages = drupal_get_messages('status');
drupal_set_message(t('Your changes have been saved.'));
 
}
 
}

If anyone has any idea why the $form_state isn't updating the fields after I save the node, any help would be great!

Updating node field value using custom module validaitonvalidation

Hello I currently have a custom module which calls a submit custom validation function,. I am trying to update a value after the validation is run. Basically, if a value is present, update a field to say "Yes".

function sitefuncs_form_alter(&$form, &$form_state, $form_id){
 
if( $form_id == 'stage_2_node_form') {
   $form['actions']['submit']['#submit'][] = 'sitefuncs_custom_submit';
}
 
} // end hook_form_alter()
 
function sitefuncs_custom_submit($form, &$form_state) {
 
        $banned = array(
        'better cures',
        'better nhs',
        'because it',
        'so what'
        );
 
  if (in_array($form_state['values']['field_stage_two_question_one']['und'][0]['value'], $banned)) { // if a banned word is the value of the input
 
$form_state['values']['field_stage_complete_text']['und'][0]['value'] = "No"; // set the value of the text input to No
 
} else {
 
$form_state['values']['field_stage_complete_text']['und'][0]['value'] = "Yes";
 
$messages = drupal_get_messages('status');
drupal_set_message(t('Your changes have been saved.'));
 
}
 
}

If anyone has any ideasidea why the $form_state$form_state isn't updating the fields after I save the node, any help would be great!

Thanks, Garry.

Updating node field value using custom module validaiton

Hello I currently have a custom module which calls a submit custom validation function, I am trying to update a value after the validation is run. Basically, if a value is present, update a field to say "Yes"

function sitefuncs_form_alter(&$form, &$form_state, $form_id){
 
if( $form_id == 'stage_2_node_form') {
   $form['actions']['submit']['#submit'][] = 'sitefuncs_custom_submit';
}
 
} // end hook_form_alter()
 
function sitefuncs_custom_submit($form, &$form_state) {
 
        $banned = array(
        'better cures',
        'better nhs',
        'because it',
        'so what'
        );
 
  if (in_array($form_state['values']['field_stage_two_question_one']['und'][0]['value'], $banned)) { // if a banned word is the value of the input
 
$form_state['values']['field_stage_complete_text']['und'][0]['value'] = "No"; // set the value of the text input to No
 
} else {
 
$form_state['values']['field_stage_complete_text']['und'][0]['value'] = "Yes";
 
$messages = drupal_get_messages('status');
drupal_set_message(t('Your changes have been saved.'));
 
}
 
}

If anyone has any ideas why the $form_state isn't updating the fields after I save the node, any help would be great!

Thanks, Garry.

Updating node field value using custom module validation

I currently have a custom module which calls a submit custom validation function. I am trying to update a value after the validation is run. Basically, if a value is present, update a field to say "Yes".

function sitefuncs_form_alter(&$form, &$form_state, $form_id){
 
if( $form_id == 'stage_2_node_form') {
   $form['actions']['submit']['#submit'][] = 'sitefuncs_custom_submit';
}
 
} // end hook_form_alter()
 
function sitefuncs_custom_submit($form, &$form_state) {
 
        $banned = array(
        'better cures',
        'better nhs',
        'because it',
        'so what'
        );
 
  if (in_array($form_state['values']['field_stage_two_question_one']['und'][0]['value'], $banned)) { // if a banned word is the value of the input
 
$form_state['values']['field_stage_complete_text']['und'][0]['value'] = "No"; // set the value of the text input to No
 
} else {
 
$form_state['values']['field_stage_complete_text']['und'][0]['value'] = "Yes";
 
$messages = drupal_get_messages('status');
drupal_set_message(t('Your changes have been saved.'));
 
}
 
}

If anyone has any idea why the $form_state isn't updating the fields after I save the node, any help would be great!

Thanks.

Source Link
Garry
  • 393
  • 2
  • 14

Updating node field value using custom module validaiton

Hello I currently have a custom module which calls a submit custom validation function, I am trying to update a value after the validation is run. Basically, if a value is present, update a field to say "Yes"

function sitefuncs_form_alter(&$form, &$form_state, $form_id){
 
if( $form_id == 'stage_2_node_form') {
   $form['actions']['submit']['#submit'][] = 'sitefuncs_custom_submit';
}
 
} // end hook_form_alter()
 
function sitefuncs_custom_submit($form, &$form_state) {
 
        $banned = array(
        'better cures',
        'better nhs',
        'because it',
        'so what'
        );
 
  if (in_array($form_state['values']['field_stage_two_question_one']['und'][0]['value'], $banned)) { // if a banned word is the value of the input
 
$form_state['values']['field_stage_complete_text']['und'][0]['value'] = "No"; // set the value of the text input to No
 
} else {
 
$form_state['values']['field_stage_complete_text']['und'][0]['value'] = "Yes";
 
$messages = drupal_get_messages('status');
drupal_set_message(t('Your changes have been saved.'));
 
}
 
}

If anyone has any ideas why the $form_state isn't updating the fields after I save the node, any help would be great!

Thanks, Garry.