I'm making a form to create an event to be download as a file .ics to be used in calendars like google agenda. I have a description field which contain a description, a link of redirection to the website and a link for the a Visio if the event is programmed in remote. I want for my description field, this scheme of display :
"description of the event"
"link of the redirection"
"link of the Visio"
when I fill my field without line break It's perfect, but when I add a line break in the description, my last line of the description and the link of the redirection are glued and the link of the Visio is disappeared
for example :
"link of the"
"redirection""link of the redirection"
some code :
controller:
public function export(Meeting $meeting, IcsProvider $ics): Response
{
$this->denyAccessUnlessGranted(MeetingVoter::VIEW, $meeting);
$cal = $ics->createCalendar(null, true);
$event = $cal->newEvent();
$link = $this->generateUrl('meeting_show', ['slug' => $meeting->getSlug()], UrlGeneratorInterface::ABSOLUTE_URL);
// Get link of redirect and Visio
$description = $meeting->getDescription()."\n\n ".$link;
if (!empty($meeting->getVisioLink())) {
$description .= "\n\nLink of visio : " . $meeting->getVisioLink();
}
// Add links for documents
if ($meeting->getDocuments()->count()) {
$description .= "\n\n document of the event : ";
foreach ($meeting->getDocuments() as $document) {
$description .= "\n" . $this->generateUrl('document_open', ['slug' => $document->getSlug()], UrlGeneratorInterface::ABSOLUTE_URL);
}
}
$event
->setStartDate($meeting->getBegin())
->setEndDate($meeting->getEnd())
->setName($meeting->getName())
->setDescription($description);
// Add place
if (!$meeting->getVisio() && !empty($meeting->getPlace())) {
$event->setLocation($meeting->getPlace());
}
return new Response(
$cal->returnCalendar(),
200,
array(
'Content-Type' => 'text/calendar; charset=utf-8',
'Content-Disposition' => 'attachment; filename="' . preg_replace('((^\.)|\/|(\.$))', '_', $meeting->getName()) . '.ics"',
)
);
}
Form:
$builder
->add('name')
->add('begin', DateTimeType::class, [
'widget' => 'single_text'
])
->add('end', DateTimeType::class, [
'widget' => 'single_text'
])
->add('visio', CheckboxType::class, ['required' => false])
->add('visioLink', TextType::class, ['required' => false])
->add('place', TextType::class, ['required' => false])
->add('description', TextareaType::class)
I can't use nl2br
, I see <br>
tags on the calendar
Someone have an idea to how can I solve that issue ?