This function (found out when debugging) totally screws Date CCK field - most of the field disappears (is not even generated).

Comments

meba’s picture

Title: nodereference_explorer_include() breaks Date CCK field » Show preview breaks other CCK fields.

Further investigation led me to:

    $references = _nodereference_potential_references($this->field, '', $match, array(), 100);

in get_item of views class.

From there, I have determined that the problem is caused by "Show preview" setting - if set, this problem occurs.

beauz’s picture

Has anyone managed to fix this?

agentrickard’s picture

Priority: Normal » Critical
Status: Active » Needs work
StatusFileSize
new724 bytes

No. I managed to confirm it. The problem is with the View generated by the nodereference module itself. It looks like the CSS and JS files are being loaded in a different order, which may be causing the problem.

It may also be better to simply load the data from a View provided by this module, rather than relying on the nodereference. There is also a bug in how the nodereference data is gathered, there is no reaqson to grab 100 items here since we know the NID.

agentrickard’s picture

As far as I can tell, it only affects fields that are themselves contained in a Fieldset.

gnindl’s picture

Version: 6.x-1.1-beta2 » 6.x-1.x-dev
Assigned: Unassigned » gnindl
Status: Needs work » Fixed

Preview is now loaded via JSON avoiding the Views CSS and JS loading. JavaScript behaviors are attached after loading. This ensures that you can still use lightbox or thickbox popups for images.

agentrickard’s picture

Status: Fixed » Needs review
StatusFileSize
new3.76 KB

Can you post a patch file? I _just_ finished working a patch based on using your own View for the Preview, rather than relying on nodereference to generate it.

I would also argue that using your own Preview view here makes a lot more sense.

gnindl’s picture

Nice patch but I would prefer to load a display from the referenced view. The preview display is then not rendered in the dialog.

Check out the current development snapshot and look at nodereference_explorer_widget_preview(), explorer.preview.js and nodereference_explorer_preview(). You should be allowed to customize the preview as you like.

The list of available preview displays is updated via JSON in the widget settings.

agentrickard’s picture

Will do. I thought I turned the block off in the dialog, see the line:

+    unset($displays['block_1']);

I should note, too, that this module is awesome. I was about to scope something just like it when I found this during a search.

agentrickard’s picture

Nice.


I edited line 65 of nodereference_explorer.widget.settings.inc to remove a formsAPI error message:
This used to be set to NULL.

Hm. That is a nasty little FormsAPI bug. It looks like we need to set the #options to array() in the form definition, and magically JS it to NULL to prevent validation errors?

agentrickard’s picture

StatusFileSize
new73.92 KB
new69.86 KB

Hitting the 'browse' button now affects the CSS for the page, altering the font, as shown below.

gnindl’s picture

Title: Show preview breaks other CCK fields. » Validation error on field settings:warning: Invalid argument supplied for foreach() in ../form.inc on line 1423.
Priority: Critical » Minor

Cannot exactly reproduce this problem but I think that it is related to this issue:

http://drupal.org/node/545354
http://drupal.org/node/545358
http://drupal.org/node/534426

CSS is now loaded on demand, i. e. when pressing the browse buttons. May preloading CSS with the node form would fix the problem.

There's an other issue with the form validation hidden here. I move the focus for this issue there.

gnindl’s picture

Status: Needs review » Active

Status change, patches welcome

p_alexander’s picture

I may be looking into this more in the near future. As an additional data point, I get the error (warning: invalid argument supplied...) on the CCK field setup page (i.e. /admin/content/node-type/custom-content-type/fields/field_custom_field). This happens with or without the preview option enabled, so it may not be related. Disabling Nodereference Explorer causes the error to disappear.

And, echoing agentrickard, this module is awesome. Thanks!

andyf’s picture

And again! Awesome module, and as with p_alexander I consistently get that message on the CCK field setup page.

andyf’s picture

Sorry if I'm repeating anything here, I don't know anything about how Drupal works... It seems that I'm having the problem referred to in #9 - form_select_options is freaking out because $element['#options'] is NULL, which as agentrickard says is set in nodereference_explorer.widget.settings.inc. I don't understand why it needs to be at one point an array and another NULL, but I'll leave that to you guys! My question: I notice the priority is set to minor - can I confirm that this is unlikely to cause problems with a site?

Thanks,

Andy

agentrickard’s picture

It's minor and doesn't affect functionality.

andyf’s picture

Thanks, great to hear!

Andy

gnindl’s picture

Status: Active » Needs review

The view displays which are available as preview displays options depend on the selection of the dialog view (content types or advanced view) in the field's widget settings. Those choices are updated via JSON on view selection. This interactivity is not understood by the Form API, as it has to know the allowed options in advance. An approach is to exclude the preview display form element from form validation (included in the current development snapshot):

$form['content']['content_preview'] = array(
      '#type' => 'select',
      '#options' => array(),
      '#title' => t('Preview display'),
      '#default_value' => isset($widget['content_preview']) ? $widget['content_preview'] : 'preview',
      '#description' => t('Leave it blank if you do not want to use any preview.'),
      '#element_validate' => array(),
      //Avoid a form error message on validation, by skipping this element, i. e. set to already validated.
      //Options are updated via JSON on the JavaScript side, so we do not know the allowed
      //values yet. Users may choose a preview display according to "View used to select the nodes" selection.
      '#validated' => true,
    );
jasonawant’s picture

Error message does not appear on the /admin/content/node-type/custom-content-type/fields/field_custom_field page.

gnindl’s picture

Version: 6.x-1.x-dev » 6.x-1.1-rc1
Status: Needs review » Fixed

Fix included in the release candidate

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.