Publisher does not support the Fluid field type. Please do not contact asking when support will be available.

If you purchased an add-on from expressionengine.com, be sure to visit boldminded.com/claim to add the license to your account here on boldminded.com.

Ticket: Using Publisher with multi-page Channel Form - fields not included in form get wiped out

Status Resolved
Add-on / Version Publisher 1.6.3
Severity
EE Version 2.10.1

Pete Heaney

Jun 01, 2015

Description: I have a multi-page Channel Form that updates the draft version of an existing entry. The exp:channel:form opening tag looks like this:

{exp:channel:form
 channel="my_channel"
 entry_id="{segment:entry_id}"
 datepicker="no"
 include_assets="no"
 include_jquery="no"
 json="yes"
 return="user/{segment:entry_id}/edit/1"
 publisher_status="draft"
}

I’m also including the hidden fields:

<input name="publisher_view_status" value="draft" type="hidden">
<input name="publisher_save_status" value="draft" type="hidden">

The multi-page nature of the Channel Form means that on any page of the form, only a subset of the form fields are submitted.  The usual behaviour of Channel Form is to ignore any fields that have been omitted from the form (i.e. leave those fields untouched).

However, when submitting a draft version of the entry via Publisher, those fields that should be ignored are being overwritten/emptied.


Detailed steps to reproduce the issue:
1. Create a template containing a channel form, specifying the entry_id of an existing entry
2. Set publisher_status=“draft”
3. Include only some of the channel fields
4. Try submitting the form and see if the fields that were not included get overwritten/emptied

#1

BoldMinded (Brian)

Hi, Pete. Thanks for the report. Based on the description and how I know Publisher works, this will involve a few changes to the codebase, so it may be a couple weeks before I have a resolution for this.

#2

Pete Heaney

I’m going to be working on this project for a few weeks at least, so I can probably work around this issue for now. So yes, if you can find some time to have a look at it in the next couple of weeks, I’d greatly appreciate it. Thanks!

#3

BoldMinded (Brian)

Comment has been marked private.

#4

BoldMinded (Brian)

Can you go to the publisher_entry.php file at line 282 and you should see this:

    if ($this->isChannelFormSubmission()) &#123;
        $this->filterPostedColumns();
    &#125;

inside that conditional, add a die(‘test’); then re-submit the form. I want to make sure its calling this function.

#5

BoldMinded (Brian)

Can you change it to this?

if ($this->isChannelFormSubmission()) {
            var_dump($this->data_columns);
            $this->filterPostedColumns();
            var_dump($this->data_columns); die;
        }

and resubmit

#6

BoldMinded (Brian)

What other fields are included in your form?

Also, please respond in the thread here, not directly via email. Others can’t search my email 😊 Thanks.

#7

Pete Heaney

Ah sorry! For the benefit of everyone else:

  • adding die(‘test’); showed that the function is being called.
  • adding the two var_dumps output the following:

var dump 1:

array(6) { ["site_id"]=> string(1) "1" ["entry_id"]=> string(3) "122" ["publisher_lang_id"]=> string(1) "1" ["publisher_status"]=> string(5) "draft" ["publisher_approval_status"]=> string(8) "approved" ["channel_id"]=> string(1) "3" }

var dump 2:

array(6) { ["site_id"]=> string(1) "1" ["entry_id"]=> string(3) "122" ["publisher_lang_id"]=> string(1) "1" ["publisher_status"]=> string(5) "draft" ["publisher_approval_status"]=> string(8) "approved" ["channel_id"]=> string(1) "3" }

It’s a multi-page form, so it depends on the page, but the form on the page I’ve been testing with includes title, url_title, plus 10 other custom fields that are just plain text input fields.

#8

BoldMinded (Brian)

The thing that worries me is the first dump should include those other 10 fields.

Before the first dump, can you add var_dump($_POST); and re-submit.

#9

Pete Heaney

Here’s the POST array dump - https://gist.github.com/peteheaney/c4e3f1c896c8c5d27e08

#10

BoldMinded (Brian)

Are you using Zoo Visitor by chance?

#11

Pete Heaney

No I’m not.

#12

BoldMinded (Brian)

Pete, I’ll do some more testing tonight to see if I can replicate the issue.

#13

BoldMinded (Brian)

This doesn’t really follow what I’m seeing locally. Here is my debugging:

removing page_checkboxes
removing page_relationship
removing page_image
removing page_assets
removing page_header
removing page_playa
removing test_field
removing page_grid
removing page_relationship_single
array(8) {
  ["site_id"]=>
  string(1) "1"
  ["entry_id"]=>
  string(3) "325"
  ["publisher_lang_id"]=>
  int(1)
  ["publisher_status"]=>
  string(5) "draft"
  ["publisher_approval_status"]=>
  string(8) "approved"
  ["page_matrix"]=>
  string(0) ""
  ["page_body"]=>
  string(26) "
aasfasdfasfasdfasf


"
  ["channel_id"]=>
  string(1) "1"
}

The matrix and body fields are the only one present in my channel form, but the other removed fields are what is in the channel field group, e.g. non-existent fields in the form, thus replicating a multi-step form.

Are you on step 1 of your form or a subsequent step? I don’t think it makes a difference to be honest, but worth a shot.

#14

BoldMinded (Brian)

E.g. removing fields means its removing it from the data_columns property, this means they are not in the SQL insert/update command, thus the current value in those fields should not be altered when the form is submitted.

Can you disable all other add-ons except for Publisher to make sure nothing is hi-jacking the $_POST global?

#15

Pete Heaney

I can’t really disable all other add-ons, so instead I setup a clean install of EE and installed just Publisher. I setup a simple channel of 4 fields and a 2 page form. I was unable to replicate the problem, which means that the issue is specific to my installation.

So I guess I need to work out which if any of my add-ons are causing the conflict. Could you tell me what steps you took to output that debugging you included above (the snippet with “removing page_checkboxes”, etc)?

Oh, and yes, I’m on step 1 of my form. Saving step 2, wipes out the data submitted on step 1.

I’m also finding that the publisher_status=”draft” channel form tag parameter doesn’t seem to work, i.e. the form displays the published version of the entry for editing rather than the draft version. This is an issue that is replicated on the clean installation, so not specific to my installation. I don’t know if this could be connected in some way, so thought I’d mention it.

#16

BoldMinded (Brian)

Thanks for the update. I’ll take a look at the draft parameter this week.

To pinpoint what other add-on may be conflicting, just make a backup of your DB with everything installed. Then uninstall 2-3 add-ons at a time and test. Eventually you should be able to narrow down which add-on may be causing the issue.

To get the output above I just used echo ‘Removing ‘. $columnName inside of the filterPostedColumns in the publisher_entry.php model. https://www.dropbox.com/s/afo63qei6iq9a0y/Screenshot 2015-06-08 07.48.55.png?dl=0

#17

Pete Heaney

Thanks. I’ll try uninstalling some add-ons.

Something else I’ve just discovered - if I change the publisher_status parameter to “open” and change the two hidden fields to:

<input name="publisher_view_status" value="open" type="hidden">
<input name="publisher_save_status" value="open" type="hidden">

the problem doesn’t occur (i.e. the data from other pages of the form is not deleted).

So maybe this is connected to the publisher_status parameter not working? But then that wouldn’t explain why it’s only a problem on my installation. Don’t know, just thinking out loud.

#18

BoldMinded (Brian)

Comment has been marked private.

#19

Pete Heaney

Thanks for the update to fix the draft issue, that worked perfectly.

It’s now become clear that the original problem is not that the fields not included in the current page of the form are being blanked out, but that the draft data is being overwritten by the published data.

I still need to try uninstalling add-ons to work out what is causing this, but let me know if you have any ideas in the meantime.

#20

Pete Heaney

Ok I’ve made some progress. That last update you made seems to have partially solved the problem. Now, it’s only the title and url_title that are being overwritten by the published version of the data. All the custom fields are not being overwritten.

I’ve replicated this problem on the clean EE installation - I’ve got a two-page form; the first page has title, url_title, and two custom fields; the second page has just two custom fields (different from the custom fields on page 1). If I change the title/url_title and submit the first page (thus creating a new draft with updated title and url_title), then submit the second page, the draft versions of the title and url_title get reverted back to the published version.

So the problem is as I described in my previous comment (the draft data is being overwritten by the published data), but it’s actually only affecting the title and url_title (at least as far as I can tell).

I tried adding ‘title’ and ‘url_title’ to the $ignoreColumns array on line 255 of publisher_entry.php, but it didn’t make any difference.

P.S. unrelated by I found another possible bug - when viewing either the draft or published version in the backend, the url_title is being populated by data from the exp_channel_data table rather than the exp_publisher_data table.

#21

BoldMinded (Brian)

Comment has been marked private.

#22

BoldMinded (Brian)

Pete, the build in the previous comment won’t automatically fix it for you. You’ll need to add this to your forms in which you don’t want the title or url_title fields to be saved. Unfortunately the values are put into the $_POST array from somewhere else so I can’t filter it like I can the other fields.

Just add this to the form:

<input name="publisher_ignore_fields" value="title|url_title" type="hidden" />
#23

Pete Heaney

Thanks Brian, that update did the trick. I was actually doing something similar as a temporary solution:

<input name="title" value="{title}" type="hidden">
<input name="url_title" value="{url_title}" type="hidden">

but this is a bit simpler I suppose.

Thanks for your help. I think you can finally close this ticket now.

Login to reply