updated forms to protect them from spamming
This commit is contained in:
parent
0a46ccb018
commit
3d4500b846
4 changed files with 50 additions and 14 deletions
|
@ -156,16 +156,17 @@ class EventController extends Controller
|
||||||
{
|
{
|
||||||
$entity = new Event();
|
$entity = new Event();
|
||||||
|
|
||||||
$em = $this->saveEvent($request, $entity);
|
if (! $request->get('origin')) {
|
||||||
|
$em = $this->saveEvent($request, $entity);
|
||||||
|
$errors = $entity->isValid();
|
||||||
$errors = $entity->isValid();
|
if ( $errors === true ) {
|
||||||
if ($errors === true) {
|
$em = $this->getDoctrine()->getManager();
|
||||||
$em = $this->getDoctrine()->getManager();
|
$em->persist($entity);
|
||||||
$em->persist($entity);
|
$em->flush();
|
||||||
$em->flush();
|
return $this->redirect($this->generateUrl('_show', array('slug' => $entity->slug)));
|
||||||
|
}
|
||||||
return $this->redirect($this->generateUrl('_show', array('slug' => $entity->slug)));
|
} else {
|
||||||
|
return $this->redirect($this->generateUrl(''));
|
||||||
}
|
}
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
|
@ -284,16 +285,18 @@ class EventController extends Controller
|
||||||
throw $this->createNotFoundException('Unable to find Event entity.');
|
throw $this->createNotFoundException('Unable to find Event entity.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$em = $this->saveEvent($request, $entity);
|
|
||||||
|
|
||||||
|
|
||||||
$errors = $entity->isValid();
|
$errors = $entity->isValid();
|
||||||
if ($errors === true) {
|
if ($errors === true && (! $request->get('origin'))) {
|
||||||
|
$em = $this->saveEvent($request, $entity);
|
||||||
$em = $this->getDoctrine()->getManager();
|
$em = $this->getDoctrine()->getManager();
|
||||||
$em->persist($entity);
|
$em->persist($entity);
|
||||||
$em->flush();
|
$em->flush();
|
||||||
|
|
||||||
return $this->redirect($this->generateUrl('_show', array('slug' => $entity->slug)));
|
return $this->redirect($this->generateUrl('_show', array('slug' => $entity->slug)));
|
||||||
|
} else {
|
||||||
|
return $this->redirect($this->generateUrl(''));
|
||||||
}
|
}
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
|
|
|
@ -178,6 +178,9 @@ class RepeatingEventController extends Controller
|
||||||
|
|
||||||
private function saveRepeatingEvent(Request $request, RepeatingEvent $entity)
|
private function saveRepeatingEvent(Request $request, RepeatingEvent $entity)
|
||||||
{
|
{
|
||||||
|
if ( $request->get('origin')) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
$location = $request->get('location');
|
$location = $request->get('location');
|
||||||
$location_lat = $request->get('location_lat');
|
$location_lat = $request->get('location_lat');
|
||||||
$location_lon = $request->get('location_lon');
|
$location_lon = $request->get('location_lon');
|
||||||
|
|
|
@ -147,7 +147,22 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="field oos">
|
||||||
|
<label class="control-label required" for="event_origin">Origin</label>
|
||||||
|
<div class="ui icon input" title="Origin URL (Screenreader: bitte leer lassen)">
|
||||||
|
<input type="text"
|
||||||
|
name="origin"
|
||||||
|
id="event_origin"
|
||||||
|
maxlength="255"
|
||||||
|
value="{{ entity.origin|default('') }}"
|
||||||
|
class="form-control">
|
||||||
|
<i class="icon globe"></i>
|
||||||
|
<div class="ui corner label">
|
||||||
|
<i class="icon asterisk"></i>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<input type="submit" class="ui button green" value="Speichern"/>
|
<input type="submit" class="ui button green" value="Speichern"/>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -157,8 +157,23 @@
|
||||||
<div class="ui label">Du kannst hier kommasepariert <a
|
<div class="ui label">Du kannst hier kommasepariert <a
|
||||||
href="https://en.wikipedia.org/wiki/Tag_%28metadata%29">Tags</a> angeben.
|
href="https://en.wikipedia.org/wiki/Tag_%28metadata%29">Tags</a> angeben.
|
||||||
</div>
|
</div>
|
||||||
|
<div class="field oos">
|
||||||
|
<label class="control-label required" for="event_origin">Origin</label>
|
||||||
|
<div class="ui icon input" title="Origin URL (Screenreader: bitte leer lassen)">
|
||||||
|
<input type="text"
|
||||||
|
name="origin"
|
||||||
|
id="event_origin"
|
||||||
|
maxlength="255"
|
||||||
|
value="{{ entity.origin|default('') }}"
|
||||||
|
class="form-control">
|
||||||
|
<i class="icon globe"></i>
|
||||||
|
<div class="ui corner label">
|
||||||
|
<i class="icon asterisk"></i>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<input type="submit" class="ui green button" value="Speichern"/>
|
<input type="submit" class="ui green button" value="Speichern"/>
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
|
|
Reference in a new issue