Topic on Talk:HTMLForm

Getting an OutPutPage object in the callback.

1
JimHu (talkcontribs)

From looking at the code in MW1.25.1 there is a feature that is not documented here. The callback sends not only the page data but also a reference to the HTMLform object itself. This means you can accept the object in your callback function and use it to get an OutPutPage object, which can be very useful for having your form do things like redirect to another page.

static function processInput( $formData, $htmlform ) {
          $t = Title::newFromText( $formData['new_page_name']);
          $content = $formData['page_content'];
          $reason = $formData['reason'];
          $p = new WikiPage($t);
          $p->save($content, $reason);
          $out = $htmlform->getOutput();
          $out->redirect($t->getFullURL());
           return true;  
}