[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class PhabricatorFormExample extends PhabricatorUIExample { 4 5 public function getName() { 6 return 'Form'; 7 } 8 9 public function getDescription() { 10 return hsprintf('Use <tt>AphrontFormView</tt> to render forms.'); 11 } 12 13 public function renderExample() { 14 $request = $this->getRequest(); 15 $user = $request->getUser(); 16 17 $start_time = id(new AphrontFormDateControl()) 18 ->setUser($user) 19 ->setName('start') 20 ->setLabel('Start') 21 ->setInitialTime(AphrontFormDateControl::TIME_START_OF_BUSINESS); 22 23 $end_time = id(new AphrontFormDateControl()) 24 ->setUser($user) 25 ->setName('end') 26 ->setLabel('End') 27 ->setInitialTime(AphrontFormDateControl::TIME_END_OF_BUSINESS); 28 29 $null_time = id(new AphrontFormDateControl()) 30 ->setUser($user) 31 ->setName('nulltime') 32 ->setLabel('Nullable') 33 ->setAllowNull(true); 34 35 if ($request->isFormPost()) { 36 $start_value = $start_time->readValueFromRequest($request); 37 $end_value = $end_time->readValueFromRequest($request); 38 $null_value = $null_time->readValueFromRequest($request); 39 } 40 41 $divider_control = new AphrontFormDividerControl(); 42 43 $credentials = array(); 44 $password_control = id(new PassphraseCredentialControl()) 45 ->setName('credentialPHID') 46 ->setLabel(pht('Password')) 47 ->setCredentialType('password') 48 ->setOptions($credentials); 49 50 $form = id(new AphrontFormView()) 51 ->setUser($user) 52 ->appendChild($start_time) 53 ->appendChild($end_time) 54 ->appendChild($null_time) 55 ->appendChild($divider_control) 56 ->appendChild($password_control) 57 ->appendChild( 58 id(new AphrontFormSubmitControl()) 59 ->setValue('Submit')); 60 61 return $form; 62 } 63 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 30 09:20:46 2014 | Cross-referenced by PHPXref 0.7.1 |