Courtyard / ForumBundle

The Courtyard ForumBundle for Symfony2.
3 stars 2 forks source link

overriding form types #5

Open gurgenhakobyan opened 11 years ago

gurgenhakobyan commented 11 years ago

Hi, can you show my how can I override forexample inline post reply form type? I created my own form type which was extending yours, created service. but it doesn't work. I just wanted to add tiny-mce class into message textarea. Is there other way to do it?

AdrianSchneider commented 11 years ago

I'd suggest doing that in the template instead of modifying the form class.

You could essentially replace the reply_inline.html.twig file with something like this...

{# render the message while adding your class #}
{{ form_widget(form.message, { attr: { class: 'your_class' } }) }}

{# render the csrf token field #}
{{ form_widget(form._token) }}

Out of scope for this reply, but you can also override the class of a service definition with a compiler pass from your own bundle (or bundle extension).

Cheers

gurgenhakobyan commented 11 years ago

Hi Adrian, thanks for the answer, I'll do that way. I just needed to know maybe later I'll have to change something in forms.

Btw, your bundle is great. Very simple and easy, I like it. Thanks for your work.