I get it working to have the checkboxes that get returned from my view into my webform, but i struggle in having them all preselected. Is there a way to preselect all checkboxes that are handled by the module?
No matter if it would be a code-hack because there is no need to make it a toggle switch in the backend for me.

Some hints would be apreciated because my knowledge of drupal and especially webform handling is very basic.

Comments

jofdesign’s picture

Priority: Normal » Major

+1 Subscribing

freakalis’s picture

Status: Active » Closed (won't fix)

You can solve this by using a hook_form_alter() and changing the webform form.

Ex. where checkbox is the field-key of your form component.

function my_module_form_alter(&$form, &$form_state, $form_id) {
  if(strpos($form_id, 'webform_client_form') !== FALSE) {
    $form['submitted']['checkbox']['#default_value'] = array_keys($form['submitted']['checkbox']['#options']); 
  }
}