Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2015
280
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.06 KB | None | 0 0
  1. public function Form() {
  2.        
  3.  
  4.         $measurement = new TextField('Measurement', 'Measurement');
  5.         $siteId = new TextField('SiteId', 'Site ID');
  6.         $recentTimeCount = DropdownField::create('recenttimecount')
  7.             ->setSource(array(0 => '1',
  8.                               1 => '2',
  9.                               1 => '3',
  10.                               1 => '4',
  11.                               1 => '5',
  12.                               1 => '6',
  13.                               1 => '10',
  14.                               1 => '12'))->setEmptyString('select');
  15.         $recentTimeUnit = DropdownField::create('recenttimeunit')
  16.             ->setSource(array(0 => 'Hour',
  17.                               1 => 'Day',
  18.                               2 => 'Week',
  19.                               3 => 'Month'))->setEmptyString('select');
  20.          $tickSpacingCount = Dropdownfield::create('tickspacingcount')
  21.             ->setSource(array(0 => '1',
  22.                               1 => '2',
  23.                               2 => '3',
  24.                               3 => '4',
  25.                               4 => '5',
  26.                               5 => '6',
  27.                               6 => '10',
  28.                               7 => '12'))->setEmptyString('select');
  29.          $tickSpacingUnit = Dropdownfield::create('tickspacingunit')
  30.             ->setSource(array(0 => 'Hour',
  31.                               1 => 'Day',
  32.                               2 => 'Week',
  33.                               3 => 'Month'))->setEmptyString('select');
  34.  
  35.         $topLabel = new TextField('toplable', 'Top Label');
  36.         $verticalLabel = new TextField('verticallabel', 'Vertical Label');
  37.         $timeRangeStart = new DateField('timerangestart', 'Start Date');
  38.         $timeRangeEnd = new DateField('timerangeend', 'End Date');
  39.  
  40.         $color = Dropdownfield::create('color')
  41.             ->setSource(array(0 => 'Red',
  42.                               1 => 'Blue'))->setEmptyString('select');
  43.         $xAxis = Dropdownfield::create('xAxis')
  44.             ->setSource(array(0 => '600',
  45.                               1 => '900',
  46.                               2 => '1200'))->setEmptyString('select');
  47.         $yAxis = Dropdownfield::create('yAxis')
  48.             ->setSource(array(0 => '300',
  49.                               1 => '450',
  50.                               2 => '600'))->setEmptyString('select');
  51.        
  52.         $returnType = 'Graph';
  53.         $fields = new FieldList(
  54.             $measurement,
  55.             $siteId,
  56.             $recentTimeCount,
  57.             $recentTimeUnit,
  58.             $tickSpacingCount,
  59.             $tickSpacingUnit,
  60.             $topLabel,
  61.             $verticalLabel,
  62.             $timeRangeStart,
  63.             $timeRangeEnd,
  64.             $color,
  65.             $xAxis,
  66.             $yAxis,
  67.             $returnType        
  68.         );
  69.  
  70.  
  71.         $validator = new RequiredFields('measurement',
  72.                                         'SiteId',
  73.                                         'recenttimecount',
  74.                                         'recenttimeunit',
  75.                                         'tickspacingcount',
  76.                                         'tickspacingunit',
  77.                                         'toplable',
  78.                                         'verticallabel',
  79.                                         'timerangestart',
  80.                                         'timerangeend',
  81.                                         'color',
  82.                                         'xAxis',
  83.                                         'yAxis');
  84.  
  85.         if ($this->HasGraphBinary())
  86.         {
  87.             $fields->push(LiteralField::create('MyGraph', '<img src="' . $this->myGraph . ' "</img>'));
  88.         }
  89.        
  90.         $action = new FormAction('doSubmit',  _t('GraphingPage.SubmitText', 'Generate Graph'));
  91.         $actions = new FieldList(
  92.             $action
  93.         );
  94.        
  95.        
  96.         $form = new Form($this, 'Form', $fields, $actions, $validator);
  97.        
  98.         return $form;
  99.        
  100.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement