X-Git-Url: https://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2Factions%2FFormAction.php;h=ec6391012ccb3cd75973623dea1572e895aa0e46;hb=db3a8beb778ba841cf6bf795312bdba796c58ee5;hp=e94a18880ed434ed9cc0abada21cd1776ff577e2;hpb=d42754e47722436ef52218f21a8e544a05ee9ad7;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/actions/FormAction.php b/includes/actions/FormAction.php index e94a18880e..ec6391012c 100644 --- a/includes/actions/FormAction.php +++ b/includes/actions/FormAction.php @@ -58,6 +58,14 @@ abstract class FormAction extends Action { protected function alterForm( HTMLForm $form ) { } + /** + * Whether the form should use OOUI + * @return bool + */ + protected function usesOOUI() { + return false; + } + /** * Get the HTMLForm to control behavior * @return HTMLForm|null @@ -68,7 +76,11 @@ abstract class FormAction extends Action { // Give hooks a chance to alter the form, adding extra fields or text etc Hooks::run( 'ActionModifyFormFields', [ $this->getName(), &$this->fields, $this->page ] ); - $form = new HTMLForm( $this->fields, $this->getContext(), $this->getName() ); + if ( $this->usesOOUI() ) { + $form = HTMLForm::factory( 'ooui', $this->fields, $this->getContext(), $this->getName() ); + } else { + $form = new HTMLForm( $this->fields, $this->getContext(), $this->getName() ); + } $form->setSubmitCallback( [ $this, 'onSubmit' ] ); $title = $this->getTitle(); @@ -97,8 +109,13 @@ abstract class FormAction extends Action { * * If you don't want to do anything with the form, just return false here. * + * This method will be passed to the HTMLForm as a submit callback (see + * HTMLForm::setSubmitCallback) and must return as documented for HTMLForm::trySubmit. + * + * @see HTMLForm::setSubmitCallback() + * @see HTMLForm::trySubmit() * @param array $data - * @return bool|array True for success, false for didn't-try, array of errors on failure + * @return bool|string|array|Status Must return as documented for HTMLForm::trySubmit */ abstract public function onSubmit( $data );