Skip to content

Commit f0c8332

Browse files
committed
v2.0.0-beta.19
1 parent 32870d1 commit f0c8332

File tree

20 files changed

+188
-121
lines changed

20 files changed

+188
-121
lines changed

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
# Solspace Freeform Changelog
22

3+
## 2.0.0-beta.19 - 2018-05-07
4+
### Added
5+
- Added optional 'Empty Option Label' input for Select fields that use the Data Feeders feature, so the first option can be `Please Select` or whatever you like.
6+
- Added 'Collect IP Addresses' setting inside Composer form setting area to disable IP address collecting per form.
7+
- Added ability to include collected IP addresses when exporting.
8+
9+
### Changed
10+
- Changed Freeform to store all numeric submission data as strings instead of integers to be more reliable.
11+
12+
### Fixed
13+
- Fixed a bug where the hidden Spam honeypot field label was missing the 'for' attribute.
14+
- Fixed a bug where the Status indicators were incorrect for the Recent Submissions widget.
15+
316
## 2.0.0-beta.18 - 2018-05-02
417
### Changed
518
- Updated Composer to no longer have a default Form Name, and also auto-generate a Form Handle based on the Form Name.

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "solspace/craft3-freeform",
33
"description": "The most intuitive and powerful form builder for Craft.",
4-
"version": "2.0.0-beta.18",
4+
"version": "2.0.0-beta.19",
55
"type": "craft-plugin",
66
"minimum-stability": "dev",
77
"authors": [
@@ -29,7 +29,7 @@
2929
}
3030
},
3131
"extra": {
32-
"schemaVersion": "2.0.9",
32+
"schemaVersion": "2.0.10",
3333
"handle": "freeform",
3434
"class": "Solspace\\Freeform\\Freeform",
3535
"name": "Freeform Lite",

src/Controllers/FormsController.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,7 @@ public function actionSave(): Response
134134
$freeform->fields,
135135
$freeform->submissions,
136136
$freeform->spamSubmissions,
137-
$freeform->mailer,
138137
$freeform->files,
139-
$freeform->mailingLists,
140-
$freeform->crm,
141138
$freeform->statuses,
142139
new CraftTranslator(),
143140
new CraftLogger()

src/Library/Composer/Components/AbstractField.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -593,11 +593,13 @@ protected function getCustomAttributes(): Attributes\CustomFieldAttributes
593593
* @param mixed $value
594594
* @param bool $escapeValue
595595
*
596+
* @param bool $insertEmpty
597+
*
596598
* @return string
597599
*/
598-
protected function getAttributeString(string $name, $value, bool $escapeValue = true): string
600+
protected function getAttributeString(string $name, $value, bool $escapeValue = true, bool $insertEmpty = false): string
599601
{
600-
if ('' !== $value) {
602+
if ('' !== $value || $insertEmpty) {
601603
return sprintf(
602604
' %s="%s"',
603605
$name,

src/Library/Composer/Components/Fields/DataContainers/Option.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ public function isChecked(): bool
7474
public function jsonSerialize()
7575
{
7676
return [
77-
'label' => $this->getLabel(),
78-
'value' => $this->getValue(),
77+
'label' => $this->getLabel(),
78+
'value' => $this->getValue(),
7979
];
8080
}
8181
}

src/Library/Composer/Components/Fields/RadioGroupField.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function getInputHtml(): string
4949
. $this->getAttributeString('type', 'radio')
5050
. $this->getAttributeString('id', $this->getIdAttribute() . "-$index")
5151
. $this->getAttributeString('class', $attributes->getClass())
52-
. $this->getAttributeString('value', $option->getValue(), false)
52+
. $this->getAttributeString('value', $option->getValue(), false, true)
5353
. $this->getParameterString('checked', $option->isChecked())
5454
. $attributes->getInputAttributesAsString()
5555
. '/>';

src/Library/Composer/Components/Fields/Traits/MultipleValueTrait.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function getValue()
2626
{
2727
$valueOverride = $this->getValueOverride();
2828
if ($valueOverride) {
29-
if (!is_array($valueOverride)) {
29+
if (!\is_array($valueOverride)) {
3030
return [$valueOverride];
3131
}
3232

@@ -35,12 +35,14 @@ public function getValue()
3535

3636
$values = $this->values;
3737

38-
if (empty($values)) {
39-
$values = [];
38+
if (!\is_array($values) && !empty($values)) {
39+
$values = [$values];
4040
}
4141

42-
if (!is_array($values)) {
43-
$values = [$values];
42+
if (empty($values)) {
43+
$values = [];
44+
} else {
45+
$values = array_map('strval', $values);
4446
}
4547

4648
return $values;

src/Library/Composer/Components/Fields/Traits/SingleValueTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function getValue()
3030
return $this->getValueOverride();
3131
}
3232

33-
return $this->value;
33+
return (string) $this->value;
3434
}
3535

3636
/**
@@ -58,7 +58,7 @@ public function setValue($value)
5858
$updatedOptions[] = new Option(
5959
$option->getLabel(),
6060
$option->getValue(),
61-
(string) $option->getValue() === (string) $objectValue
61+
$option->getValue() === (string) $objectValue
6262
);
6363
}
6464

src/Library/Composer/Components/Form.php

Lines changed: 43 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
use Solspace\Freeform\Library\Logging\LoggerInterface;
3030
use Solspace\Freeform\Library\Session\FormValueContext;
3131
use Solspace\Freeform\Library\Translations\TranslatorInterface;
32-
use Solspace\Freeform\Models\FieldModel;
3332

3433
class Form implements \JsonSerializable, \Iterator, \ArrayAccess
3534
{
@@ -63,6 +62,9 @@ class Form implements \JsonSerializable, \Iterator, \ArrayAccess
6362
/** @var bool */
6463
private $storeData;
6564

65+
/** @var bool */
66+
private $ipCollectingEnabled;
67+
6668
/** @var int */
6769
private $defaultStatus;
6870

@@ -123,16 +125,16 @@ class Form implements \JsonSerializable, \Iterator, \ArrayAccess
123125
/**
124126
* Form constructor.
125127
*
126-
* @param Properties $properties
127-
* @param FormAttributes $formAttributes
128-
* @param array $layoutData
129-
* @param FormHandlerInterface $formHandler
130-
* @param FieldHandlerInterface $fieldHandler
131-
* @param SubmissionHandlerInterface $submissionHandler
132-
* @param SpamSubmissionHandlerInterface $spamSubmissionHandler
133-
* @param FileUploadHandlerInterface $fileUploadHandler
134-
* @param TranslatorInterface $translator
135-
* @param LoggerInterface $logger
128+
* @param Properties $properties
129+
* @param FormAttributes $formAttributes
130+
* @param array $layoutData
131+
* @param FormHandlerInterface $formHandler
132+
* @param FieldHandlerInterface $fieldHandler
133+
* @param SubmissionHandlerInterface $submissionHandler
134+
* @param SpamSubmissionHandlerInterface $spamSubmissionHandler
135+
* @param FileUploadHandlerInterface $fileUploadHandler
136+
* @param TranslatorInterface $translator
137+
* @param LoggerInterface $logger
136138
*
137139
* @throws FreeformException
138140
* @throws \Solspace\Freeform\Library\Exceptions\Composer\ComposerException
@@ -149,18 +151,18 @@ public function __construct(
149151
TranslatorInterface $translator,
150152
LoggerInterface $logger
151153
) {
152-
$this->properties = $properties;
153-
$this->formHandler = $formHandler;
154-
$this->fieldHandler = $fieldHandler;
155-
$this->submissionHandler = $submissionHandler;
156-
$this->spamSubmissionHandler = $spamSubmissionHandler;
157-
$this->fileUploadHandler = $fileUploadHandler;
158-
$this->translator = $translator;
159-
$this->logger = $logger;
160-
$this->storeData = true;
161-
$this->customAttributes = new CustomFormAttributes();
162-
$this->errors = [];
163-
$this->markedAsSpam = false;
154+
$this->properties = $properties;
155+
$this->formHandler = $formHandler;
156+
$this->fieldHandler = $fieldHandler;
157+
$this->submissionHandler = $submissionHandler;
158+
$this->spamSubmissionHandler = $spamSubmissionHandler;
159+
$this->fileUploadHandler = $fileUploadHandler;
160+
$this->translator = $translator;
161+
$this->logger = $logger;
162+
$this->storeData = true;
163+
$this->ipCollectingEnabled = true;
164+
$this->customAttributes = new CustomFormAttributes();
165+
$this->errors = [];
164166

165167
$this->layout = new Layout(
166168
$this,
@@ -322,6 +324,14 @@ public function getDefaultStatus(): int
322324
return $this->defaultStatus;
323325
}
324326

327+
/**
328+
* @return int
329+
*/
330+
public function isIpCollectingEnabled(): bool
331+
{
332+
return (bool) $this->ipCollectingEnabled;
333+
}
334+
325335
/**
326336
* @return bool
327337
*/
@@ -513,7 +523,7 @@ public function submit()
513523
if ($this->storeData && $this->hasOptInPermission()) {
514524
$submission = $this->saveStoredStateToDatabase();
515525
} else {
516-
$submission = $this->getSubmissionHandler()->createSubmissionFromForm($this);
526+
$submission = $this->getSubmissionHandler()->createSubmissionFromForm($this);
517527
$this->formSaved = true;
518528
}
519529

@@ -578,7 +588,7 @@ public function getMailingListOptedInFields(): array
578588
{
579589
$fields = [];
580590
foreach ($this->getLayout()->getMailingListFields() as $field) {
581-
$field = $this->getLayout()->getFieldByHandle($field->getHandle());
591+
$field = $this->getLayout()->getFieldByHandle($field->getHandle());
582592
$fieldValue = $field->getValue();
583593
if ($fieldValue && $field->getEmailFieldHash() && $field->getResourceId()) {
584594
$fields[] = $field;
@@ -588,7 +598,7 @@ public function getMailingListOptedInFields(): array
588598
return $fields;
589599
}
590600

591-
/**
601+
/**
592602
* Render a predefined template
593603
*
594604
* @param array $customFormAttributes
@@ -797,6 +807,7 @@ private function buildFromData(FormProperties $formProperties)
797807
$this->description = $formProperties->getDescription();
798808
$this->returnUrl = $formProperties->getReturnUrl();
799809
$this->storeData = $formProperties->isStoreData();
810+
$this->ipCollectingEnabled = $formProperties->isIpCollectingEnabled();
800811
$this->defaultStatus = $formProperties->getDefaultStatus();
801812
$this->formTemplate = $formProperties->getFormTemplate();
802813
$this->optInDataStorageTargetHash = $formProperties->getOptInDataStorageTargetHash();
@@ -876,7 +887,8 @@ private function saveStoredStateToDatabase()
876887
*
877888
* @throws \Solspace\Freeform\Library\Exceptions\Composer\ComposerException
878889
*/
879-
public function getAdminNotificationProperties() {
890+
public function getAdminNotificationProperties()
891+
{
880892
return $this->properties->getAdminNotificationProperties();
881893
}
882894

@@ -885,7 +897,8 @@ public function getAdminNotificationProperties() {
885897
*
886898
* @return DynamicNotificationAttributes|null
887899
*/
888-
public function getDynamicNotificationData() {
900+
public function getDynamicNotificationData()
901+
{
889902
return $this->getFormValueContext()->getDynamicNotificationData();
890903
}
891904

@@ -1024,7 +1037,8 @@ public function offsetUnset($offset)
10241037
throw new FreeformException('Form ArrayAccess does not allow unsetting values');
10251038
}
10261039

1027-
private function isLastPage() {
1040+
private function isLastPage()
1041+
{
10281042
return $this->getFormValueContext()->getCurrentPageIndex() === (\count($this->getPages()) - 1);
10291043
}
10301044
}

src/Library/Composer/Components/Layout.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ private function buildLayout(FormValueContext $formValueContext)
296296
$mailingListFields = [];
297297

298298
foreach ($this->layoutData as $pageIndex => $rows) {
299-
if (!is_array($rows)) {
299+
if (!\is_array($rows)) {
300300
throw new ComposerException(
301301
$this->translate(
302302
'Layout page {pageIndex} does not contain a row array',

0 commit comments

Comments
 (0)