0

Using drupal 7 and Webform (both up2date), how can I alter the default value of a "Select options" field?

I tried to do this:

function mymodul_webform_component_render_alter (&$element, &$component) {
if( $element['#type'] == 'select' && 
      $element['#title'] == 'field1' ) {
$element['#default_value'] = 'bar,foo';}
}

But it's not working...

I can make it work with a single default value if I set the field to "Listbox", what I don't want. But I still can bypass this "if" statement... But still can't set the default value to multiple choices

regards

1

For multiple selects use an array for the default value:

$element['#default_value'] = array('foo', 'bar');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.