| 1 | <?php |
||
| 10 | class SalesForceSignupForm extends Form |
||
| 11 | { |
||
| 12 | |||
| 13 | private static $allowed_actions = [ |
||
|
1 ignored issue
–
show
|
|||
| 14 | 'doSalesForceSignUp' => true |
||
| 15 | ]; |
||
| 16 | |||
| 17 | private static $based_on_instance_of = 'SalesForceContact'; |
||
|
1 ignored issue
–
show
|
|||
| 18 | |||
| 19 | /** |
||
| 20 | * Our constructor only requires the controller and the name of the form |
||
| 21 | * method. We'll create the fields and actions in here. |
||
| 22 | * |
||
| 23 | */ |
||
| 24 | public function __construct($controller, $name) |
||
| 25 | { |
||
| 26 | $fields = $this->getBaseFields(); |
||
| 27 | |||
| 28 | $actions = $this->getBaseAction(); |
||
| 29 | |||
| 30 | $required = $this->getBaseRequiredFields(); |
||
| 31 | |||
| 32 | // now we create the actual form with our fields and actions defined |
||
| 33 | // within this class |
||
| 34 | parent::__construct($controller, $name, $fields, $actions, $required); |
||
| 35 | |||
| 36 | // any modifications we need to make to the form. |
||
| 37 | $this->loadDataFrom($_REQUEST); |
||
| 38 | } |
||
| 39 | |||
| 40 | |||
| 41 | public function setSigupFields(array $fieldArray) |
||
| 42 | { |
||
| 43 | $newList = new FieldList(); |
||
| 44 | $oldFields = $this->Fields(); |
||
| 45 | foreach($fieldsArray as $field) { |
||
| 46 | $newField = $oldFields->dataFieldByName($field); |
||
| 47 | $newList->push($newField); |
||
| 48 | } |
||
| 49 | |||
| 50 | $this->setFields($newList); |
||
| 51 | |||
| 52 | return $this; |
||
| 53 | } |
||
| 54 | |||
| 55 | public function setRequiredFields(array $fieldArray) |
||
| 56 | { |
||
| 57 | $this->setRequiredFields(new RequiredFields($fieldArray)); |
||
| 58 | |||
| 59 | return $this; |
||
| 60 | } |
||
| 61 | |||
| 62 | |||
| 63 | public function setFormSubmitText(string $label) |
||
| 71 | } |
||
| 72 | |||
| 73 | protected function getBaseFields() |
||
| 79 | |||
| 80 | } |
||
| 81 | |||
| 82 | protected function getBaseAction() |
||
| 86 | ); |
||
| 87 | } |
||
| 88 | |||
| 89 | protected function getBaseRequiredFields() |
||
| 96 | ] |
||
| 97 | ); |
||
| 98 | } |
||
| 99 | |||
| 100 | |||
| 101 | public function doSalesForceSignUp($data, Form $form) |
||
| 105 | } |
||
| 106 | |||
| 107 | |||
| 108 | } |
||
| 109 |