I have a content type generated by simplenews. I added an extra nodereference field, that is linked to a views, that outputs every 'active' node from the 'news' content type (by active I mean every news node has an expiry date, after which they are not active anymore). It works well, except...

How can I make each of these news to be selected to be sent with my newsletter by default? Most of the cases I'd like to attach all of these news, but still I would like to have the option to exclude news, so it would be nice if I had them selected already.

Thanks for the help, I hope I posted it to the right place.

Comments

citricguy’s picture

Were you able to accomplish this? I'm looking to do the same thing in d7.

citricguy’s picture

I'm sure there is a better way to do this, but I was able to select all fields by default by using a #after_build function.

added the following with hook_form_alter():

$form['#after_build'][] = '_check_everything';

Here are the contents of the _check_everything function.

function _check_everything($form, &$form_state) {
    foreach($form['field_included_review_sites'][LANGUAGE_NONE]['#options'] as $key => $data) {
        $form['field_included_review_sites'][LANGUAGE_NONE][$key]['#checked'] = TRUE;
    }
    return $form;
}

Quick and dirty, but it works. Will likely refactor and re post later.