Mam sobie moduł "newsletter_history", który generuję za pomocą "symfony generate-admin". Stworzyłem sobie partiala "_newsletter_attachments" w "newsletter_history/templates", który ma wypisywać nazwy załączników danego newslettera.
Problem w tym, że partial działa tylko na liście, zaś w edycji już nie. Wyrzuca błąd "Notice: Undefined variable: NewsletterHistory". Z tego co czytałem ten obiekt powinien być dostępny w partialu właśnie pod nazwą klasy - tylko dlaczego na liście jest dostępny a w edycji nie?
Oto fragment pliku generator.yml:
Kod
list:
hide: [ body ]
display: [id, created_at, title, is_free, _newsletter_attachments]
edit:
display: [id, title, body, _newsletter_attachments]
hide: [ body ]
display: [id, created_at, title, is_free, _newsletter_attachments]
edit:
display: [id, title, body, _newsletter_attachments]
Cała zawartość "newsletter_history/config/generator.yml":
Kod
generator:
class: sfPropelGenerator
param:
model_class: NewsletterHistory
theme: admin
non_verbose_templates: true
with_show: false
singular: NewsletterHistory
plural: NewsletterHistorys
route_prefix: newsletter_history
with_propel_route: 1
actions_base_class: sfActions
config:
actions: ~
fields:
created_at: { label: Data utworzenia, date_format: "yyyy-MM-dd, HH:mm"}
is_free: { label: Czy darmowy }
list:
hide: [ body ]
display: [id, created_at, title, is_free, _newsletter_attachments]
filter: ~
form: ~
edit:
display: [id, title, body, _newsletter_attachments]
new: ~
class: sfPropelGenerator
param:
model_class: NewsletterHistory
theme: admin
non_verbose_templates: true
with_show: false
singular: NewsletterHistory
plural: NewsletterHistorys
route_prefix: newsletter_history
with_propel_route: 1
actions_base_class: sfActions
config:
actions: ~
fields:
created_at: { label: Data utworzenia, date_format: "yyyy-MM-dd, HH:mm"}
is_free: { label: Czy darmowy }
list:
hide: [ body ]
display: [id, created_at, title, is_free, _newsletter_attachments]
filter: ~
form: ~
edit:
display: [id, title, body, _newsletter_attachments]
new: ~
Zawartość "newsletter_history/templates/_newsletter_attachments.php":
Kod
<?php
$arr01 = $NewsletterHistory->getNewsletterAttachmentss();
foreach($arr01 as $attachment) {
echo $attachment->getName() . "<br>";
}
?>
$arr01 = $NewsletterHistory->getNewsletterAttachmentss();
foreach($arr01 as $attachment) {
echo $attachment->getName() . "<br>";
}
?>