Closed (won't fix)
Project:
Webform
Version:
6.x-3.18
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
2 Jan 2013 at 18:29 UTC
Updated:
18 Jun 2013 at 04:20 UTC
I'm trying to programmatically edit the values of a checkbox component through hook_form_alter, but even if the rendered values are correct, only the original values are submitted.
Here is my code:
function my_form_webform_client_form_30_alter (&$form, &$form_state) {
$form = mycustom_form($form);
}
function mycustom_form($form){
$form['#validate'][] = 'mycustom_webform_validate_form';
$form['#submit'][] = 'mycustom_webform_submit';
dpm($form['submitted']['code']['#options']); // ('0'=>'a value', '1'=>'another value');
$codes = array('foo', 'bar');
foreach ($codes as $key => $value) {
$form['submitted']['code']['#options'][$value] = $value;
}
dpm($form['submitted']['code']['#options']); // ('0'=>'a value', '1'=>'another value', '2'=>'foo', '3'=>'bar' );
return $form;
}
function mycustom_webform_validate_form($form, &$form_state) {
dpm($form_state['values']['submitted']);
// selecting all checkboxes I get all the four values
}
function mycustom_webform_validate_form($form, &$form_state) {
drupal_set_message('<pre>' . print_r($form_state, true) . '</pre>');
// only 'a value' and 'another value' are submitted
}
What am I doing wrong?
Comments
Comment #1
quicksketchAs mentioned in the submission guidelines, we don't provide help with custom coding:
Please refer to other resources such as IRC or Drupal StackExchange to ask your questions.