When creating a new node, I get this error:
Invalid argument supplied for foreach()
/var/www/drupal/includes/form.inc
Line 1206
which is
foreach ($form['#default_value'] as $key) {
$value[$key] = 1;
}
and is coming from domain.module: Line 1560
...
$form['domain']['domain_site'] = array(
'#type' => 'checkbox',
'#prefix' => t('<p><b>Publishing options:</b>'),
'#suffix' => '</p>',
'#title' => t('Send to all affiliates'),
'#required' => FALSE,
'#description' => t('Select if this content can be shown to all affiliates. This setting will override the options below, but you must still select a domain that "owns" this content.'),
'#default_value' => (isset($form['#node']->nid)) ? $form['#node']->domain_site : variable_get('domain_node_'. $form['#node']->type, $behavior),
);
$form['domain']['domains'] = array(
'#type' => empty($format) ? 'checkboxes' : 'select',
'#title' => t('Publish to'),
'#options' => $options,
'#required' => TRUE,
'#description' => t('Select which affiliates can access this content.'),
'#default_value' => (isset($form['#node']->nid)) ? $form['#node']->domains : $default,
);
...
The problem is that #default_value is NULL because (isset($form['#node']->nid)) should be (isset($form['#node']->nid) && $form['#node']->nid > 0) for both $form['domain']['domain_site']['#default_value'] and $form['domain']['domains']['#default_value']
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | 721352-isset.patch | 2.77 KB | agentrickard |
| #2 | Picture 1.png | 47.73 KB | agentrickard |
Comments
Comment #1
fizk commentedIn general, I think that the checkbox logic needs to be put into one place and hidden behind a function.
In other words, that should only show up once. I've hit problems with checkboxes a few times already while using other domain modules.
Comment #2
agentrickardPatches welcome. The 'cannot pass zero in checkboxes' is a core limitation that we have to work around, and the new form style (which allows separate formats) hasn't been consolidated. That should be spun off as a separate issue. The problem there is reconciling the form names and a few other minor discrepancies among each usage.
I am curious what modules or settings you have, because I can't replicate the error in #1. When I create a new node, $form['#node']->nid is not set (see attached). Even when set to NULL on preview, I don't get this error.
Looking at the code, it looks like #default_value should in fact be:
And the same below.
Comment #3
fizk commentedI was creating a new Support ticket. The module has been giving me so many problems right out of the box, I just disabled it.
I didn't get this problem before installing Support, and I'm pretty sure it wouldn't have happened when creating other types of nodes.
Comment #4
fizk commentedSpin off issue: #721858: Checkbox logic needs to be put into one place.
Comment #5
agentrickardInteresting. I think the approach I describe in #2 is still probably best. Here's a quick patch.
Comment #6
agentrickardCommitted!