[COMPONENT] Posts scope initial form

This commit is contained in:
rainydaysavings 2020-08-22 01:24:55 +01:00 committed by Hugo Sales
parent 9442556c3e
commit dec35a6aa1

View File

@ -29,6 +29,7 @@ use App\Entity\FileToNote;
use App\Entity\Note; use App\Entity\Note;
use App\Util\Common; use App\Util\Common;
use Component\Media\Media; use Component\Media\Media;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\FileType; use Symfony\Component\Form\Extension\Core\Type\FileType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType; use Symfony\Component\Form\Extension\Core\Type\TextareaType;
@ -41,10 +42,25 @@ class Posting extends Module
return; return;
} }
$to_options = ['public' => _m('public'), 'instance' => _m('instance')];
$id = Common::actor()->getId();
$to_tags = DB::dql('select c.tag from App\Entity\GSActorCircle c where c.tagger = :tagger', ['tagger' => $id]);
foreach ($to_tags as $t) {
$t = $t['tag'];
$to_options[$t] = $t;
}
$request = $vars['request']; $request = $vars['request'];
$form = Form::create([ $form = Form::create([
['content', TextareaType::class, ['label' => ' ']], ['content', TextareaType::class, ['label' => ' ']],
['attachments', FileType::class, ['label' => _m('Attachments'), 'multiple' => true, 'required' => false]], ['attachments', FileType::class, ['label' => _m('Attachments'), 'multiple' => true, 'required' => false]],
['scope', ChoiceType::class, [
'label' => 'To:',
'multiple' => true,
'expanded' => true,
'choices' => $to_options,
]],
['send', SubmitType::class, ['label' => _m('Send')]], ['send', SubmitType::class, ['label' => _m('Send')]],
]); ]);
$form->handleRequest($request); $form->handleRequest($request);
@ -52,7 +68,6 @@ class Posting extends Module
$data = $form->getData(); $data = $form->getData();
if ($form->isValid()) { if ($form->isValid()) {
$content = $data['content']; $content = $data['content'];
$id = Common::actor()->getId();
$note = Note::create(['gsactor_id' => $id, 'content' => $content]); $note = Note::create(['gsactor_id' => $id, 'content' => $content]);
$files = []; $files = [];
foreach ($data['attachments'] as $f) { foreach ($data['attachments'] as $f) {