Skip to content

Commit

Permalink
fix: fatal error when not filling a date
Browse files Browse the repository at this point in the history
Signed-off-by: Thierry Bugier <tbugier@teclib.com>
  • Loading branch information
btry committed Feb 16, 2021
1 parent d47099a commit 940bfee
Show file tree
Hide file tree
Showing 20 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion inc/field/actorfield.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ public function getValueForDesign(): string {
return implode("\r\n", $value);
}

public function getValueForTargetText($richText): string {
public function getValueForTargetText($richText): ?string {
$value = [];
foreach ($this->value as $item) {
if (filter_var($item, FILTER_VALIDATE_EMAIL) !== false) {
Expand Down
2 changes: 1 addition & 1 deletion inc/field/checkboxesfield.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ public function hasInput($input): bool {
return isset($input['formcreator_field_' . $this->question->getID()]);
}

public function getValueForTargetText($richText): string {
public function getValueForTargetText($richText): ?string {
$value = [];
$values = $this->getAvailableValues();

Expand Down
2 changes: 1 addition & 1 deletion inc/field/datefield.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public function getValueForDesign(): string {
return $this->value;
}

public function getValueForTargetText($richText): string {
public function getValueForTargetText($richText): ?string {
return Html::convDate($this->value);
}

Expand Down
2 changes: 1 addition & 1 deletion inc/field/datetimefield.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public function hasInput($input): bool {
return isset($input['formcreator_field_' . $this->question->getID()]);
}

public function getValueForTargetText($richText): string {
public function getValueForTargetText($richText): ?string {
return Html::convDateTime($this->value);
}

Expand Down
2 changes: 1 addition & 1 deletion inc/field/descriptionfield.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function getValueForDesign(): string {
return '';
}

public function getValueForTargetText($richText): string {
public function getValueForTargetText($richText): ?string {
$text = $this->question->fields['description'];
if (!$richText) {
$text = nl2br(strip_tags(html_entity_decode($text)));
Expand Down
2 changes: 1 addition & 1 deletion inc/field/dropdownfield.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ public function getValueForDesign(): string {
return $this->value;
}

public function getValueForTargetText($richText): string {
public function getValueForTargetText($richText): ?string {
$DbUtil = new DbUtils();
$itemtype = $this->getSubItemtype();
if ($itemtype == User::class) {
Expand Down
2 changes: 1 addition & 1 deletion inc/field/filefield.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public function getValueForDesign(): string {
return '';
}

public function getValueForTargetText($richText): string {
public function getValueForTargetText($richText): ?string {
return $this->value;
}

Expand Down
2 changes: 1 addition & 1 deletion inc/field/floatfield.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public function getValueForDesign(): string {
return $this->value;
}

public function getValueForTargetText($richText): string {
public function getValueForTargetText($richText): ?string {
return $this->value;
}

Expand Down
2 changes: 1 addition & 1 deletion inc/field/hiddenfield.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public static function getName(): string {
return _n('Hidden field', 'Hidden fields', 1);
}

public function getValueForTargetText($richText): string {
public function getValueForTargetText($richText): ?string {
return str_replace("\n", '\r\n', $this->value);
}

Expand Down
2 changes: 1 addition & 1 deletion inc/field/hostnamefield.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public function getValueForDesign(): string {
return '';
}

public function getValueForTargetText($richText): string {
public function getValueForTargetText($richText): ?string {
return $this->value;
}

Expand Down
2 changes: 1 addition & 1 deletion inc/field/ipfield.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public function getValueForDesign(): string {
return $this->value;
}

public function getValueForTargetText($richText): string {
public function getValueForTargetText($richText): ?string {
return $this->value;
}

Expand Down
2 changes: 1 addition & 1 deletion inc/field/radiosfield.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ public function getValueForDesign(): string {
return $this->value;
}

public function getValueForTargetText($richText): string {
public function getValueForTargetText($richText): ?string {
return $this->value;
}

Expand Down
2 changes: 1 addition & 1 deletion inc/field/requesttypefield.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public function hasInput($input): bool {
return isset($input['formcreator_field_' . $this->question->getID()]);
}

public function getValueForTargetText($richText): string {
public function getValueForTargetText($richText): ?string {
$available = $this->getAvailableValues();
return $available[$this->value];
}
Expand Down
2 changes: 1 addition & 1 deletion inc/field/tagfield.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public function getValueForDesign(): string {
return implode("\r\n", $this->value);
}

public function getValueForTargetText($richText): string {
public function getValueForTargetText($richText): ?string {
$value = Dropdown::getDropdownName(PluginTagTag::getTable(), $this->value);
return $value;
}
Expand Down
2 changes: 1 addition & 1 deletion inc/field/textareafield.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ public function parseAnswerValues($input, $nonDestructive = false): bool {
return true;
}

public function getValueForTargetText($richText): string {
public function getValueForTargetText($richText): ?string {
$value = $this->value;
if (!$richText) {
$value = Toolbox::unclean_cross_side_scripting_deep($value);
Expand Down
2 changes: 1 addition & 1 deletion inc/field/textfield.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public function getValueForDesign(): string {
return $this->value;
}

public function getValueForTargetText($richText): string {
public function getValueForTargetText($richText): ?string {
return $this->value;
}

Expand Down
2 changes: 1 addition & 1 deletion inc/field/timefield.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public function getValueForDesign(): string {
return $this->value;
}

public function getValueForTargetText($richText): string {
public function getValueForTargetText($richText): ?string {
$date = DateTime::createFromFormat("H:i:s", $this->value);
if ($date === false) {
return ' ';
Expand Down
2 changes: 1 addition & 1 deletion inc/field/urgencyfield.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ public function getValueForDesign(): string {
return $this->value;
}

public function getValueForTargetText($richText): string {
public function getValueForTargetText($richText): ?string {
$available = $this->getAvailableValues();
return $available[$this->value];
}
Expand Down
2 changes: 1 addition & 1 deletion inc/fieldinterface.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public function getValueForDesign() : string;
*
* @return string
*/
public function getValueForTargetText($richText) : string;
public function getValueForTargetText($richText): ?string;

/**
* Move uploaded files and make Document items
Expand Down
2 changes: 1 addition & 1 deletion tests/fixture/PluginFormcreatorDependentField.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public function getValueForDesign(): string {
return $this->value;
}

public function getValueForTargetText($richText): string {
public function getValueForTargetText($richText): ?string {
return Toolbox::addslashes_deep($this->value);
}

Expand Down

0 comments on commit 940bfee

Please sign in to comment.