CwpCommentingExtension::alterCommentForm()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 14
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 9
c 1
b 0
f 0
nc 4
nop 1
dl 0
loc 14
rs 9.9666
1
<?php
2
3
namespace CWP\CWP\Extensions;
4
5
use SilverStripe\Control\Email\Email;
6
use SilverStripe\Core\Extension;
7
use SilverStripe\Forms\Form;
8
9
/**
10
 * Customises the comment form to conform to government usability standards
11
 *
12
 * {@see CommentingController}
13
 * @skipUpgrade
14
 */
15
class CwpCommentingExtension extends Extension
16
{
17
    public function alterCommentForm(Form $form)
18
    {
19
        $fields = $form->Fields();
20
21
        if ($emailField = $fields->dataFieldByName('Email')) {
22
            $emailField
23
                ->setTitle(_t(__CLASS__ . '.EMAIL_TITLE', 'Email'))
24
                ->setDescription(_t(__CLASS__ . '.WILL_NOT_BE_PUBLISHED', 'Will not be published.'));
25
        }
26
27
        if ($urlField = $fields->dataFieldByName('URL')) {
28
            $urlField
29
                ->setTitle(_t(__CLASS__ . '.WEBSITE_TITLE', 'Your website (optional)'))
30
                ->setAttribute('placeholder', 'http://');
31
        }
32
    }
33
}
34