Remove document_name from block data.

Fixes #2
This commit is contained in:
buttle 2021-09-07 01:05:05 +02:00
parent 8aed07719e
commit 310f1c531a
2 changed files with 3 additions and 9 deletions

View File

@ -76,9 +76,5 @@ class TechDocumentBlockForm extends Form
'rows' => '10', 'rows' => '10',
], ],
]); ]);
$this->add([
'name' => 'o:block[__blockIndex__][o:data][document_name]',
'type' => Element\Hidden::class,
]);
} }
} }

View File

@ -66,8 +66,8 @@ class TechDocument extends AbstractBlockLayout
{ {
$data = $block->getData(); $data = $block->getData();
$site_title = $block->getPage()->getSite()->getTitle(); $site_title = $block->getPage()->getSite()->getTitle();
//$file_name = preg_replace( '/[^a-z0-9]+/', '-', strtolower( $site_title ) );
$site_url = null; $site_url = null;
//$site_url = $block->getPage()->getSite()->url();
$parsedown = new Parsedown(); $parsedown = new Parsedown();
# logo -> link to site page # logo -> link to site page
@ -87,7 +87,8 @@ class TechDocument extends AbstractBlockLayout
$text .= "\n\n### Long-term Care: (in storage and on display)\n"; $text .= "\n\n### Long-term Care: (in storage and on display)\n";
$text .= $data['longtermcare']; $text .= $data['longtermcare'];
$document_name = $data['document_name']; $document_name = preg_replace('/[^a-z0-9]+/', '-', strtolower( $site_title )).'.pdf';
$html = $parsedown->setBreaksEnabled(true)->text($text); $html = $parsedown->setBreaksEnabled(true)->text($text);
$mpdf = new \Mpdf\Mpdf(); $mpdf = new \Mpdf\Mpdf();
$mpdf->SetHTMLFooter(' $mpdf->SetHTMLFooter('
@ -111,8 +112,6 @@ class TechDocument extends AbstractBlockLayout
SitePageBlockRepresentation $block = null SitePageBlockRepresentation $block = null
) { ) {
$form = $this->formElementManager->get(TechDocumentBlockForm::class); $form = $this->formElementManager->get(TechDocumentBlockForm::class);
$site_title = $view->site->title();
$file_name = preg_replace( '/[^a-z0-9]+/', '-', strtolower($site_title) ).'.pdf';
$data = $block $data = $block
? $block->data() + $this->defaultSettings ? $block->data() + $this->defaultSettings
: $this->defaultSettings; : $this->defaultSettings;
@ -123,7 +122,6 @@ class TechDocument extends AbstractBlockLayout
'o:block[__blockIndex__][o:data][installation]' => $data['installation'], 'o:block[__blockIndex__][o:data][installation]' => $data['installation'],
'o:block[__blockIndex__][o:data][shipping]' => $data['shipping'], 'o:block[__blockIndex__][o:data][shipping]' => $data['shipping'],
'o:block[__blockIndex__][o:data][longtermcare]' => $data['longtermcare'], 'o:block[__blockIndex__][o:data][longtermcare]' => $data['longtermcare'],
'o:block[__blockIndex__][o:data][document_name]' => $file_name,
]); ]);
$form->prepare(); $form->prepare();