'type' => 'text',
'name' => 'page',
'label-message' => 'newsection-page',
+ 'required' => true,
],
], $this->getContext(), 'newsection' );
$form->setSubmitTextMsg( 'newsection-submit' );
public function onFormSubmit( $formData ) {
$title = $formData['page'];
- $page = Title::newFromText( $title );
+ try {
+ $page = Title::newFromTextThrow( $title );
+ } catch ( MalformedTitleException $e ) {
+ return Status::newFatal( $e->getMessageObject() );
+ }
$query = [ 'action' => 'edit', 'section' => 'new' ];
$url = $page->getFullUrlForRedirect( $query );
$this->getOutput()->redirect( $url );