Skip to content

Commit

Permalink
Fixes missing URL value in. Hotspot info
Browse files Browse the repository at this point in the history
  • Loading branch information
DiegoPino committed Apr 19, 2021
1 parent 58d58e6 commit 5a3ac71
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/Element/WebformPanoramaTour.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Drupal\webform_strawberryfield\Element;

use Drupal\Component\Utility\UrlHelper;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Render\Element\FormElement;
use Drupal\webform\Element\WebformCompositeBase;
Expand Down Expand Up @@ -838,8 +839,17 @@ public static function addHotspotSubmit(
$newid = Uuid::uuid4();
$hotspot->id = $element_name . '_' . $current_scene . '_' . $newid->toString();
if ($hotspot->type == 'url') {
$hotspot->URL = $hotspot->url;
$hotspot->type = 'info';
$externalURL = $form_state->getValue(
[$element_name, 'hotspots_temp', 'url']
);
if (UrlHelper::isValid(trim($externalURL), TRUE)) {
$hotspot->URL = $externalURL;
$hotspot->type = 'info';
}
else {
$form_state->setRebuild(TRUE);
return;
}
}
if ($hotspot->type == 'ado') {
$nodeid = $form_state->getValue(
Expand Down Expand Up @@ -881,7 +891,6 @@ public static function addHotspotSubmit(
$hotspot->text = $hotspot->text;
$hotspot->type = 'info';
}

$existing_objects[] = (array) $hotspot;

// @TODO make sure people don't add twice the same coordinates!
Expand All @@ -892,7 +901,6 @@ public static function addHotspotSubmit(
$form_state->set($all_scenes_key, $allscenes);
$form_state->setValue([$element_name, 'allscenes'], json_encode($allscenes));


} else {
// Do we alert the user? Form needs to be restarted
static::messenger()->addError(t('Something bad happened with the Tour builder, sadly you will have you restart your session.'));
Expand Down Expand Up @@ -1014,7 +1022,7 @@ public static function deleteHotSpot(array &$form, FormStateInterface $form_stat
}

$form_state->set($all_scenes_key, $allscenes);
$form_state->setValue([$element_name, 'allscenes'],json_encode($allscenes));
$form_state->setValue([$element_name, 'allscenes'], json_encode($allscenes));


} else {
Expand Down

0 comments on commit 5a3ac71

Please sign in to comment.