1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
/**
 * Defines the StandardFormPage page type
 */

class StandardFormPage extends Page {
	static $db = array(
		'Headline' => 'Text',
		'Summary' => 'Text'
	);
	static $has_one = array(
	);
	static $has_many = array(
   );
	
	
	function getCMSFields() {
		$fields = parent::getCMSFields();
		
		$fields->addFieldToTab('Root.Content.Main', new TextField('Headline'), 'Content');
		$fields->addFieldToTab('Root.Content.Main', new TextField('Summary'), 'Content');
								
		return $fields;
	}
	
	/*
	function validate() {
		$myValidator = parent::validate();
		
		$myValidator->error('No value is assigned');
		
		return $myValidator;
		
	}*/
	public function getCMSValidator() {
		$validator = new CustomRequiredFields(
			array(
				"Title",
				'Headline',
				'Summary',
				array(
					"php" => 'if($data["Headline"] == "CC") {
					    $this->validationError( "Headline", "Headline is invalid", "required");
					}
					if($data["Summary"] == "CC") {
					    $this->validationError( "Summary", "Summary is invalid", "required");
					}',
				),
			)
		);
		
		return $validator;	
      //return new RequiredFields(array('Title', 'Headline', 'Content'));
   }
}

class StandardFormPage_Controller extends Page_Controller {
	
}
?>