Jump to content

jordanlev

Members
  • Posts

    69
  • Joined

  • Last visited

Community Answers

  1. jordanlev's post in Problems with image uploads when including ProcessEditPage form on another admin page was marked as the answer   
    Well, after a ton of debugging and stepping through code, I've begun to understand what the problems I was having are. Unfortunately these require very specific fixes to the way that specific inputfields work (there's not some global setting), so I would imagine that there are other field types I haven't gotten to yet that will cause problems as well. But for what it's worth, here is how to fix the issue with the image uploader widget and the CKEditor image button:
    IMAGE FIELD (2 things required):
    * The image uploader needs to make an ajax request to the ProcessPageEdit page (/processwire/page/edit), but instead of using the actual url to that page it retrieves the form action. Since I've changed the form action to post back to my own page, this was resulting in the ajax call not getting what I needed. To fix this, I added this at the very beginning of my "executeEditMyPage()" function:
    if ($this->config->ajax) { return $this->modules->get('ProcessPageEdit')->execute(); } * The image uploader needs to know what page it is working with, so add this somewhere on the page (it can live anywhere on the page, but I'm adding it as an "InputfieldMarkup" field to the form so everything is self-contained there): $form->add($modules->get("InputfieldMarkup")->set('name', 'PageIDIndicator')->set('value', "<p id='PageIDIndicator'>{$page->id}</p>")); (note that the image uploader only needs that p tag, but I am also setting a "name" on the inputfield so that the generated markup gets an id I can then hide via css, like so: #Inputfield_PageIDIndicator { display: none; })CKEDITOR IMAGE BUTTON (1 thing required):
    * The ckeditor image plugin needs to know what page it is working with, but it looks for a different element than the image uploader widget does. So add this to the form as well (this actually needs to be a form field):
    $form->add($modules->get("InputfieldHidden")->set('name', 'id')->set('value', $page->id)); VOILA!Wish me luck when it comes time to figure out Repeater and PageTable
×
×
  • Create New...