nodechanges_form_alter() injects a textarea field (as per #1733658: Inject a comment body text area and input format selector into the node edit form) to a node edit form, which is used to populate a real comment body or similar field on submission of the node edit form.

However, if you have customised your Comments fields and added additional fields, none of those fields will be rendered.

I propose that instead of jamming a textarea field into the nod edit form, we attach all the Comment fields to the form (excluding the changes field).

Working on a solution.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

drumm’s picture

Deciphered’s picture

Status: Active » Needs review
FileSize
9.94 KB

As promised.

Important notes:

  • Pseudo field is renamed from 'nodechanges_comment_body' to 'nodechanges_comment' for seemingly obvious reasons, but the weight from the old pseudo field will be lost. Probably worth add a hook_update_N() function.
  • All comment fields are being set to not required, otherwise it would not be possible to save the node edit form without filling in said required fields, such as the Comment body field. This is debatable as being necessary, it might be worth arguing that the Comment body should be required, or that it's up to the site admin to make the call. Seemed like the appropriate thing to do for the moment.
  • Preview of comment is an actual rendered comment instead of just the one textfield. Could be reverted back to the textfield.

I think that pretty much covers it.

drumm’s picture

#1561780: Tests would be nice to have right now.

Agreed on all your notes, especially adding the hook_update_N().

Preview of comment is an actual rendered comment instead of just the one textfield. Could be reverted back to the textfield.

I think the whole comment preview is good to see.

  • drumm committed e0189e2 on 7.x-1.x authored by Deciphered
    Issue #2416177 by Deciphered: Use Comment fields instead of custom...
drumm’s picture

I went ahead and pushed #2. I haven't run into any problems with it yet.

drumm’s picture

Issue tags: +needs drupal.org deployment
drumm’s picture

Issue tags: -needs drupal.org deployment

  • drumm committed b615e49 on 7.x-1.x
    Issue #2416177: Fix notice on node add
    
formatC'vt’s picture

hm, i have subscription for all issues but don't receive e-mail about this one =)
good idea and i found a bug in ckeditor module with already deleted $form['nodechanges_comment_body'] element =)

formatC'vt’s picture

i think we should fill comment with user data and put comment in preview mode.
Patch attached.

  • drumm committed 1f2d020 on 7.x-1.x authored by formatC'vt
    Issue #2416177 by formatC'vt: Fill comment with user data and put...
drumm’s picture

Good idea, committed.

drumm’s picture

Status: Needs review » Needs work

I found an Entity Reference field does not save properly because the field_attach_* functions need to be called, eventually calling _field_filter_items().

  • drumm committed 793b181 on 7.x-1.x
    Issue #2416177: Call field_attach_form_validate() and...
drumm’s picture

That commit covers field_attach_form_validate() and field_attach_submit(). That's enough to get an Entity Reference field working. I think there are other field_attach_* calls missing. There may be some more cleanup that can be done.

formatC'vt’s picture

Now we have a node edit form with attached comment fields, i think we also need a comment edit form with attached node fields.
I want to use nodechanges with ajax_comments module =)

drumm’s picture

Status: Needs work » Fixed

Let's call this done. Other issues can be opened as followups.

Status: Fixed » Closed (fixed)

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