Skip to content

Commit 3ba4884

Browse files
author
github-actions
committed
tidy
1 parent c35c6ac commit 3ba4884

16 files changed

+343
-286
lines changed
Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
<?php
2+
/**
3+
* src/FormFields/EditableHTML5DateField.php
4+
*
5+
* @package default
6+
*/
7+
28

39
namespace Logicbrush\UserFormsUtils\FormFields;
410

@@ -13,16 +19,21 @@ use SilverStripe\UserForms\Model\EditableFormField;
1319
*/
1420
class EditableHTML5DateField extends EditableFormField {
1521

16-
private static $singular_name = 'HTML5 Date Field';
17-
private static $plural_name = 'HTML5 Date Fields';
18-
private static $table_name = 'EditableHTML5DateField';
19-
20-
public function getFormField() {
21-
$field = HTML5DateField::create($this->Name, $this->Title ?: false)
22-
->setFieldHolderTemplate(EditableFormField::class . '_holder')
23-
;
24-
$this->doUpdateFormField($field);
25-
return $field;
26-
}
22+
private static $singular_name = 'HTML5 Date Field';
23+
private static $plural_name = 'HTML5 Date Fields';
24+
private static $table_name = 'EditableHTML5DateField';
25+
26+
/**
27+
*
28+
* @return unknown
29+
*/
30+
public function getFormField() {
31+
$field = HTML5DateField::create($this->Name, $this->Title ?: false)
32+
->setFieldHolderTemplate(EditableFormField::class . '_holder')
33+
;
34+
$this->doUpdateFormField($field);
35+
return $field;
36+
}
37+
2738

2839
}
Lines changed: 34 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
<?php
2+
/**
3+
* src/FormFields/EditableSignatureField.php
4+
*
5+
* @package default
6+
*/
7+
28

39
namespace Logicbrush\UserFormsUtils\FormFields;
410

@@ -10,27 +16,34 @@ use SilverStripe\UserForms\Model\Submission\SubmittedFormField;
1016

1117
class EditableSignatureField extends EditableFormField {
1218

13-
private static $singular_name = 'Signature Field';
14-
private static $plural_name = 'Signature Fields';
15-
private static $table_name = 'EditableSignatureField';
16-
17-
public function getFormField() {
18-
$field = TextField::create($this->Name, $this->Title ?: false)
19-
->setFieldHolderTemplate(EditableFormField::class . '_holder')
20-
->setTemplate(EditableSignatureField::class)
21-
;
22-
$this->doUpdateFormField($field);
23-
return $field;
24-
}
25-
26-
/**
27-
* Returns an image field, so the signature can be viewed in the CMS and in
28-
* reports.
29-
*/
30-
public function getSubmittedFormField() : SubmittedFormField
31-
{
32-
return ImageSubmittedFormField::create();
33-
}
19+
private static $singular_name = 'Signature Field';
20+
private static $plural_name = 'Signature Fields';
21+
private static $table_name = 'EditableSignatureField';
22+
23+
/**
24+
*
25+
* @return unknown
26+
*/
27+
public function getFormField() {
28+
$field = TextField::create($this->Name, $this->Title ?: false)
29+
->setFieldHolderTemplate(EditableFormField::class . '_holder')
30+
->setTemplate(EditableSignatureField::class)
31+
;
32+
$this->doUpdateFormField($field);
33+
return $field;
34+
}
35+
36+
37+
/**
38+
* Returns an image field, so the signature can be viewed in the CMS and in
39+
* reports.
40+
*
41+
* @return unknown
42+
*/
43+
public function getSubmittedFormField() : SubmittedFormField
44+
{
45+
return ImageSubmittedFormField::create();
46+
}
3447

3548

3649
}

src/FormFields/.EditableUSStateDropdownField.php.phptidybak~

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,10 @@ class EditableUSStateDropdownField extends EditableFormField {
8989
];
9090

9191
/**
92-
*
93-
* @return FieldList
94-
*/
95-
public function getCMSFields() {
92+
*
93+
* @return FieldList
94+
*/
95+
public function getCMSFields() {
9696
$this->beforeUpdateCMSFields(function (FieldList $fields) {
9797
$fields->removeByName('Default');
9898
$fields->addFieldToTab(
@@ -155,7 +155,7 @@ class EditableUSStateDropdownField extends EditableFormField {
155155
$source = $this->getFormField()->getSource();
156156
return $source[$data[$this->Name]];
157157
}
158-
return null;
158+
return null;
159159
}
160160

161161

src/FormFields/EditableHTML5DateField.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ class EditableHTML5DateField extends EditableFormField {
2828
* @return unknown
2929
*/
3030
public function getFormField() {
31-
$field = HTML5DateField::create($this->Name, $this->Title ?: false)
32-
->setFieldHolderTemplate(EditableFormField::class . '_holder')
31+
$field = HTML5DateField::create( $this->Name, $this->Title ?: false )
32+
->setFieldHolderTemplate( EditableFormField::class . '_holder' )
3333
;
34-
$this->doUpdateFormField($field);
34+
$this->doUpdateFormField( $field );
3535
return $field;
3636
}
3737

src/FormFields/EditableSignatureField.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ class EditableSignatureField extends EditableFormField {
2525
* @return unknown
2626
*/
2727
public function getFormField() {
28-
$field = TextField::create($this->Name, $this->Title ?: false)
29-
->setFieldHolderTemplate(EditableFormField::class . '_holder')
30-
->setTemplate(EditableSignatureField::class)
28+
$field = TextField::create( $this->Name, $this->Title ?: false )
29+
->setFieldHolderTemplate( EditableFormField::class . '_holder' )
30+
->setTemplate( EditableSignatureField::class )
3131
;
32-
$this->doUpdateFormField($field);
32+
$this->doUpdateFormField( $field );
3333
return $field;
3434
}
3535

src/FormFields/EditableUSStateDropdownField.php

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -93,26 +93,26 @@ class EditableUSStateDropdownField extends EditableFormField {
9393
* @return FieldList
9494
*/
9595
public function getCMSFields() {
96-
$this->beforeUpdateCMSFields(function (FieldList $fields) {
97-
$fields->removeByName('Default');
96+
$this->beforeUpdateCMSFields( function ( FieldList $fields ) {
97+
$fields->removeByName( 'Default' );
9898
$fields->addFieldToTab(
9999
'Root.Main',
100-
DropdownField::create('Default', _t(self::class . '.DEFAULT', 'Default value'))
101-
->setSource(self::$list_of_states)
102-
->setHasEmptyDefault(true)
103-
->setEmptyString('---')
100+
DropdownField::create( 'Default', _t( self::class . '.DEFAULT', 'Default value' ) )
101+
->setSource( self::$list_of_states )
102+
->setHasEmptyDefault( true )
103+
->setEmptyString( '---' )
104104
);
105105

106106
$fields->addFieldToTab(
107107
'Root.Main',
108-
CheckboxField::create('UseEmptyString', _t(self::class . '.USE_EMPTY_STRING', 'Set default empty string'))
108+
CheckboxField::create( 'UseEmptyString', _t( self::class . '.USE_EMPTY_STRING', 'Set default empty string' ) )
109109
);
110110

111111
$fields->addFieldToTab(
112112
'Root.Main',
113-
TextField::create('EmptyString', _t(self::class . '.EMPTY_STRING', 'Empty String'))
113+
TextField::create( 'EmptyString', _t( self::class . '.EMPTY_STRING', 'Empty String' ) )
114114
);
115-
});
115+
} );
116116

117117
return parent::getCMSFields();
118118
}
@@ -123,23 +123,23 @@ public function getCMSFields() {
123123
* @return unknown
124124
*/
125125
public function getFormField() {
126-
$field = DropdownField::create($this->Name, $this->Title ?: false)
127-
->setFieldHolderTemplate(EditableFormField::class . '_holder')
128-
->setTemplate(EditableDropdown::class)
129-
->setSource(self::$list_of_states)
126+
$field = DropdownField::create( $this->Name, $this->Title ?: false )
127+
->setFieldHolderTemplate( EditableFormField::class . '_holder' )
128+
->setTemplate( EditableDropdown::class )
129+
->setSource( self::$list_of_states )
130130
;
131131

132132
// Empty string
133-
if ($this->UseEmptyString) {
134-
$field->setEmptyString($this->EmptyString ?: '');
133+
if ( $this->UseEmptyString ) {
134+
$field->setEmptyString( $this->EmptyString ?: '' );
135135
}
136136

137137
// Set default
138-
if ($this->Default) {
139-
$field->setValue($this->Default);
138+
if ( $this->Default ) {
139+
$field->setValue( $this->Default );
140140
}
141141

142-
$this->doUpdateFormField($field);
142+
$this->doUpdateFormField( $field );
143143

144144
return $field;
145145
}
@@ -150,8 +150,8 @@ public function getFormField() {
150150
* @param unknown $data
151151
* @return unknown
152152
*/
153-
public function getValueFromData($data) {
154-
if (!empty($data[$this->Name])) {
153+
public function getValueFromData( $data ) {
154+
if ( ! empty( $data[$this->Name] ) ) {
155155
$source = $this->getFormField()->getSource();
156156
return $source[$data[$this->Name]];
157157
}
@@ -164,9 +164,9 @@ public function getValueFromData($data) {
164164
* @return unknown
165165
*/
166166
public function getIcon() {
167-
$resource = ModuleLoader::getModule('silverstripe/userforms')->getResource('images/editabledropdown.png');
167+
$resource = ModuleLoader::getModule( 'silverstripe/userforms' )->getResource( 'images/editabledropdown.png' );
168168

169-
if (!$resource->exists()) {
169+
if ( ! $resource->exists() ) {
170170
return '';
171171
}
172172

@@ -176,11 +176,10 @@ public function getIcon() {
176176

177177
/**
178178
*
179-
* @param EditableCustomRule $rule
180-
* @param unknown $forOnLoad (optional)
179+
* @param unknown $forOnLoad (optional)
181180
* @return unknown
182181
*/
183-
public function getSelectorField(EditableCustomRule $rule, $forOnLoad = false) {
182+
public function getSelectorField( EditableCustomRule $rule, $forOnLoad = false ) {
184183
return "$(\"select[name='{$this->Name}']\")";
185184
}
186185

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,39 @@
11
<?php
2+
/**
3+
* src/FormFields/Impl/HTML5DateField.php
4+
*
5+
* @package default
6+
*/
7+
28

39
namespace Logicbrush\UserFormsUtils\FormFields\Impl;
410

511
use SilverStripe\Forms\DateField;
612

713
class HTML5DateField extends DateField {
814

9-
public function __construct($name, $title = null, $value = "")
10-
{
11-
parent::__construct($name, $title, $value);
12-
$this->setHTML5(true);
13-
}
14-
15-
16-
public function getAttributes()
17-
{
18-
return array_merge(
19-
parent::getAttributes(),
20-
array(
21-
'type' => 'date'
22-
)
23-
);
24-
}
15+
/**
16+
*
17+
* @param unknown $name
18+
* @param unknown $title (optional)
19+
* @param unknown $value (optional)
20+
*/
21+
public function __construct($name, $title = null, $value = "") {
22+
parent::__construct($name, $title, $value);
23+
$this->setHTML5(true);
24+
}
25+
26+
27+
/**
28+
*
29+
* @return unknown
30+
*/
31+
public function getAttributes() {
32+
return array_merge(
33+
parent::getAttributes(),
34+
['type' => 'date']
35+
);
36+
}
37+
2538

2639
}

src/FormFields/Impl/HTML5DateField.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ class HTML5DateField extends DateField {
1818
* @param unknown $title (optional)
1919
* @param unknown $value (optional)
2020
*/
21-
public function __construct($name, $title = null, $value = "") {
22-
parent::__construct($name, $title, $value);
23-
$this->setHTML5(true);
21+
public function __construct( $name, $title = null, $value = "" ) {
22+
parent::__construct( $name, $title, $value );
23+
$this->setHTML5( true );
2424
}
2525

2626

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
<?php
2+
/**
3+
* src/FormFields/Submission/ImageSubmittedFormField.php
4+
*
5+
* @package default
6+
*/
7+
28

39
namespace Logicbrush\UserFormsUtils\FormFields\Submission;
410

@@ -7,15 +13,19 @@ use SilverStripe\UserForms\Model\Submission\SubmittedFormField;
713

814
class ImageSubmittedFormField extends SubmittedFormField {
915

10-
public function getFormattedValue()
11-
{
12-
if ($this->Value) {
13-
return DBField::create_field('HTMLText', sprintf(
14-
'<img src="data:%s" />',
15-
htmlspecialchars($this->Value, ENT_QUOTES)
16-
));
17-
}
18-
return false;
19-
}
16+
/**
17+
*
18+
* @return unknown
19+
*/
20+
public function getFormattedValue() {
21+
if ($this->Value) {
22+
return DBField::create_field('HTMLText', sprintf(
23+
'<img src="data:%s" />',
24+
htmlspecialchars($this->Value, ENT_QUOTES)
25+
));
26+
}
27+
return false;
28+
}
29+
2030

2131
}

src/FormFields/Submission/ImageSubmittedFormField.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ class ImageSubmittedFormField extends SubmittedFormField {
1818
* @return unknown
1919
*/
2020
public function getFormattedValue() {
21-
if ($this->Value) {
22-
return DBField::create_field('HTMLText', sprintf(
21+
if ( $this->Value ) {
22+
return DBField::create_field( 'HTMLText', sprintf(
2323
'<img src="data:%s" />',
24-
htmlspecialchars($this->Value, ENT_QUOTES)
25-
));
24+
htmlspecialchars( $this->Value, ENT_QUOTES )
25+
) );
2626
}
2727
return false;
2828
}

0 commit comments

Comments
 (0)