1 | <?php |
||
2 | |||
3 | namespace DNADesign\Elemental\Tests\Src; |
||
4 | |||
5 | use DNADesign\Elemental\Controllers\ElementController; |
||
6 | use SilverStripe\Dev\TestOnly; |
||
7 | use SilverStripe\Forms\FieldList; |
||
8 | use SilverStripe\Forms\Form; |
||
9 | use SilverStripe\Forms\FormAction; |
||
10 | use SilverStripe\Forms\TextField; |
||
11 | |||
12 | class TestElementController extends ElementController implements TestOnly |
||
13 | { |
||
14 | private static $url_segment = 'test-page'; |
||
0 ignored issues
–
show
introduced
by
Loading history...
|
|||
15 | |||
16 | private static $allowed_actions = array( |
||
17 | 'Form' |
||
18 | ); |
||
19 | |||
20 | public function Form() |
||
21 | { |
||
22 | $elementform = new Form( |
||
23 | $this, |
||
24 | 'Form', |
||
25 | new FieldList( |
||
26 | new TextField('TestValue') |
||
27 | ), |
||
28 | new FieldList( |
||
29 | new FormAction('doAction') |
||
30 | ) |
||
31 | ); |
||
32 | |||
33 | return $elementform; |
||
34 | } |
||
35 | |||
36 | public function doAction($data, $form) |
||
37 | { |
||
38 | return sprintf( |
||
39 | 'TestValue: %s\nElement ID: %d', |
||
40 | $data['TestValue'], |
||
41 | $this->element->ID |
||
42 | ); |
||
43 | } |
||
44 | } |
||
45 |