Skip to content

Commit 3f3e5ef

Browse files
committed
Update template class
1 parent e94a68f commit 3f3e5ef

File tree

4 files changed

+6
-26
lines changed

4 files changed

+6
-26
lines changed

src/controllers/PartialUserFormController.php

+6-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Firesphere\PartialUserforms\Controllers;
44

5+
use Page;
56
use Firesphere\PartialUserforms\Models\PartialFormSubmission;
67
use SilverStripe\Control\HTTPRequest;
78
use SilverStripe\Control\Middleware\HTTPCacheControlMiddleware;
@@ -62,7 +63,8 @@ public function partial(HTTPRequest $request)
6263
$this->setFailover($this->dataRecord);
6364

6465
$form = $this->Form();
65-
$form->loadDataFrom($partial->getFieldList());
66+
$fields = $partial->PartialFields()->map('Name', 'Value')->toArray();
67+
$form->loadDataFrom($fields);
6668

6769
// Copied from {@link UserDefinedFormController}
6870
if ($this->Content && $form && !$this->config()->disable_form_content_shortcode) {
@@ -75,19 +77,20 @@ public function partial(HTTPRequest $request)
7577
$formEscapedForRegex,
7678
$this->Content
7779
);
80+
7881
return $this->customise([
7982
'Content' => DBField::create_field('HTMLText', $content),
8083
'Form' => '',
8184
'PartialLink' => $partial->getPartialLink()
82-
])->renderWith(['Firesphere\PartialUserforms\PartialUserForm', 'Page']);
85+
])->renderWith([static::class, Page::class]);
8386
}
8487
}
8588

8689
return $this->customise([
8790
'Content' => DBField::create_field('HTMLText', $this->Content),
8891
'Form' => $form,
8992
'PartialLink' => $partial->getPartialLink()
90-
])->renderWith(['Firesphere\PartialUserforms\PartialUserForm', 'Page']);
93+
])->renderWith([static::class, Page::class]);
9194
} else {
9295
return $this->httpError(404);
9396
}

src/models/PartialFormSubmission.php

-17
Original file line numberDiff line numberDiff line change
@@ -212,21 +212,4 @@ public function generateKey($token)
212212
{
213213
return hash_pbkdf2('sha256', $token, $this->TokenSalt, 1000, 16);
214214
}
215-
216-
/**
217-
* Get the partial fields in array
218-
*
219-
* @return array
220-
*/
221-
public function getFieldList()
222-
{
223-
$list = [];
224-
if ($this->PartialFields()->exists()) {
225-
foreach ($this->PartialFields() as $field) {
226-
$list[$field->Name] = $field->Value;
227-
}
228-
}
229-
230-
return $list;
231-
}
232215
}

tests/unit/PartialFormSubmissionTest.php

-6
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,6 @@ public function testGenerateKey()
139139
$this->assertEquals(16, strlen($key));
140140
}
141141

142-
public function testGetFieldList()
143-
{
144-
$partial = PartialFormSubmission::create();
145-
$this->assertEmpty($partial->getFieldList());
146-
}
147-
148142
protected function setUp()
149143
{
150144
parent::setUp();

0 commit comments

Comments
 (0)