-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(events): add a selector for easier event comparison
- Loading branch information
1 parent
12c0ec8
commit c628ff0
Showing
6 changed files
with
80 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<div class="ui violet segment"> | ||
{{ form_start(form) }} | ||
<div class="ui form"> | ||
<div class="inline fields"> | ||
<div class="field"> | ||
{{ form_label(form.id, 'Comparer à') }} | ||
{{ form_widget(form.id, {attr: {onchange:'this.name="id"; this.form.submit(); return false;'}}) }} | ||
</div> | ||
</div> | ||
</div> | ||
{{ form_end(form) }} | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
|
||
namespace AppBundle\Event\Form; | ||
|
||
use AppBundle\Event\Model\Event; | ||
use AppBundle\Event\Model\Repository\EventRepository; | ||
use Symfony\Component\Form\AbstractType; | ||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType; | ||
use Symfony\Component\Form\FormBuilderInterface; | ||
use Symfony\Component\HttpFoundation\Request; | ||
use Symfony\Component\OptionsResolver\OptionsResolver; | ||
|
||
class EventCompareSelectType extends AbstractType | ||
{ | ||
/** @var EventRepository */ | ||
private $eventRepository; | ||
|
||
public function __construct(EventRepository $eventRepository) | ||
{ | ||
$this->eventRepository = $eventRepository; | ||
} | ||
|
||
public function buildForm(FormBuilderInterface $builder, array $options) | ||
{ | ||
$builder | ||
->add('id', ChoiceType::class, | ||
[ | ||
'choice_label' => 'title', | ||
'choice_value' => 'id', | ||
'data' => $options['data'] ?? null, | ||
'choices' => $this->eventRepository->getPreviousEvents(), | ||
] | ||
) | ||
->setMethod(Request::METHOD_GET) | ||
; | ||
} | ||
|
||
public function configureOptions(OptionsResolver $resolver) | ||
{ | ||
$resolver->setDefaults([ | ||
'data_class' => Event::class, | ||
'csrf_protection' => false | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters