1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-02-17 17:28:42 +01:00
phorge-phorge/src/applications/uiexample/examples/PhabricatorPagedFormExample.php
epriestley e1bd868142 Minor, fix the PagedForm UIExample
Summary: A couple of features got added when this was used in Diffusion, but
didn't get backported to the UIExample.

See: <https://github.com/facebook/phabricator/issues/454>

Auditors: btrahan
2013-11-26 08:57:17 -08:00

71 lines
1.8 KiB
PHP

<?php
final class PhabricatorPagedFormExample extends PhabricatorUIExample {
public function getName() {
return pht('Form (Paged)');
}
public function getDescription() {
return pht(
'Use %s to render forms with multiple pages.',
hsprintf('<tt>PHUIPagedFormView</tt>'));
}
public function renderExample() {
$request = $this->getRequest();
$user = $request->getUser();
$page1 = id(new PHUIFormPageView())
->setPageName(pht('Page 1'))
->addControl(
id(new AphrontFormTextControl())
->setName('page1')
->setLabel('Page 1'));
$page2 = id(new PHUIFormPageView())
->setPageName(pht('Page 2'))
->addControl(
id(new AphrontFormTextControl())
->setName('page2')
->setLabel('Page 2'));
$page3 = id(new PHUIFormPageView())
->setPageName(pht('Page 3'))
->addControl(
id(new AphrontFormTextControl())
->setName('page3')
->setLabel('Page 3'));
$page4 = id(new PHUIFormPageView())
->setPageName(pht('Page 4'))
->addControl(
id(new AphrontFormTextControl())
->setName('page4')
->setLabel('Page 4'));
$form = new PHUIPagedFormView();
$form->setUser($user);
$form->addPage('page1', $page1);
$form->addPage('page2', $page2);
$form->addPage('page3', $page3);
$form->addPage('page4', $page4);
if ($request->isFormPost()) {
$form->readFromRequest($request);
if ($form->isComplete()) {
return id(new AphrontDialogView())
->setUser($user)
->setTitle(pht('Form Complete'))
->appendChild(pht('You submitted the form. Well done!'))
->addCancelButton($request->getRequestURI(), pht('Again!'));
}
} else {
$form->readFromObject(null);
}
return $form;
}
}