New form type which is not captcha really. Bugfix for exception.
This commit is contained in:
parent
bec53995a0
commit
07126b5586
|
@ -29,6 +29,8 @@ framework:
|
|||
twig:
|
||||
debug: "%kernel.debug%"
|
||||
strict_variables: "%kernel.debug%"
|
||||
form_themes:
|
||||
- 'SkobkinCopyPasteBundle:Form:fields.html.twig'
|
||||
|
||||
# Assetic Configuration
|
||||
assetic:
|
||||
|
|
|
@ -30,6 +30,12 @@ class CopypasteController extends Controller
|
|||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isValid()) {
|
||||
// Check "captcha"
|
||||
// @todo check internally in transformation or somewhere else
|
||||
if (null === $form->get('captcha')->getData()) {
|
||||
throw $this->createNotFoundException('This isn\'t the service you\'re spamming to.');
|
||||
}
|
||||
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
if ($form->get('private')->getData()) {
|
||||
|
@ -57,7 +63,7 @@ class CopypasteController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
throw new $this->createAccessDeniedException('Sorry :(');
|
||||
throw $this->createAccessDeniedException('Sorry :(');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -66,6 +66,10 @@ class CopypasteType extends AbstractType
|
|||
},
|
||||
//'preferred_choices' => []
|
||||
])
|
||||
->add('captcha', 'skobkin_fake_captcha', [
|
||||
'mapped' => false,
|
||||
'required' => true,
|
||||
])
|
||||
->add('actions', 'form_actions')
|
||||
;
|
||||
}
|
||||
|
|
32
src/Skobkin/Bundle/CopyPasteBundle/Form/FakeCaptchaType.php
Normal file
32
src/Skobkin/Bundle/CopyPasteBundle/Form/FakeCaptchaType.php
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
namespace Skobkin\Bundle\CopyPasteBundle\Form;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class FakeCaptchaType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'label' => false,
|
||||
]);
|
||||
}
|
||||
|
||||
public function getParent()
|
||||
{
|
||||
return 'hidden';
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return 'skobkin_fake_captcha';
|
||||
}
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
services:
|
||||
# skobkin_copy_paste.example:
|
||||
# class: Skobkin\Bundle\CopyPasteBundle\Example
|
||||
# arguments: [@service_id, "plain_value", %parameter%]
|
||||
copypaste.form.type.fake_captcha:
|
||||
class: Skobkin\Bundle\CopyPasteBundle\Form\FakeCaptchaType
|
||||
tags:
|
||||
- { name: form.type, alias: skobkin_fake_captcha }
|
|
@ -0,0 +1,16 @@
|
|||
{% block skobkin_fake_captcha_widget %}
|
||||
{% spaceless %}
|
||||
<div id="{{ form.vars.id }}"></div>
|
||||
<script type="text/javascript">
|
||||
(function () {
|
||||
div = document.getElementById('{{ form.vars.id }}');
|
||||
input = document.createElement('input');
|
||||
input.setAttribute('type', 'hidden');
|
||||
input.setAttribute('name', '{{ form.vars.full_name }}');
|
||||
input.setAttribute('value', 'dumb_text');
|
||||
div.appendChild(input);
|
||||
console.log(div);
|
||||
})();
|
||||
</script>
|
||||
{% endspaceless %}
|
||||
{% endblock %}
|
Loading…
Reference in a new issue