I'm trying to put together a form to collect PDF files from people along with some metadata (title, authors, night of their presentation, etc) to put into a table and to let people upload updated versions of those PDFs later on.
I thought I'd use the Bureaucracy plugin's Fieldset Dependencies feature to:
* Only collect metadata and create table entries via pagemod for new submissions
* Omit metadata collection and table entry addition when just uploading an update PDF file
So far, I'm able to get the following to work:
* New submissions that require metadata collection and table entry addition work as expected
* Uploading updated versions of previously uploaded files works (after some work) [0]
But, when just uploading an updated file, the pagemod actions still get triggered which cause entries like these to show up in the table when what I want is no new table entry, just to upload a new version of the already uploaded PDF file
| {{events:event:pdfs:jkuroda.pdf|@@Poster Title@@}} | Jon Kuroda | @@Night@@ | |
My wiki markup looks like this:
<sortable>
^ Title ^ Author(s) ^ Night ^ Notes ^
<pagemod table output_before>| {{events:event:pdfs:@@Filename@@|@@Title@@}} | @@Authors@@ | @@Night@@ | @@Notes|@@ |</pagemod>
</sortable>
<form>
fieldset "Add or Update Your PDF"
select "Adding or Updating" "Adding|Updating"
fieldset "Add your PDF" "Adding or Updating" "Adding"
action pagemod _self table
textbox "Title"
textbox "Authors" =@NAME@
select "Night" "Wednesday|Thursday"
textbox "Notes" !
action template _ events:event:pdfs:@@Filename@@
file "Filename" ..:
fieldset "Update your poster" "Adding or Updating" "Updating"
action template _ events:event:pdfs:@@Filename@@
file "Filename" ..:
fieldset ""
submit
</form>
Or in pseudocode:
if adding a new PDf
collect metadata
update table via pagemod
upload PDf
else // just uploading new version of already uploaded PDF
// do not collect metadata
// do not update table via pagemod
upload PDF // overwrite previously uploaded PDF
This generates a form that appears to behave as expected - it doesn't collect metadata if one selects "updating" - but the table still gets updated using default or placeholder template values. Do Bureaucracy actions in a form always trigger regardless of Fieldset Dependencies? I can do this with two forms - one for new submissions, one for updates, but that's super clunky; or I could figure out the Data or Struct plugins, but I don't have enough time for that for this particular event.
[0] Normally, Bureaucracy is hardcoded to not allow overwriting already uploaded files via forms created using the "file" fieldtype (processUploads() in helper/actiontemplate.php hardcodes media_save()'s $ow argument to false), but for this, I hardcoded it to true to allow media file overwriting. I've got some code that breaks that out into a parameter that can be turned on via a new constraint to the file fieldtype that will enable file overwriting, but I need to clean it up before submitting it for an RFE.