tags:

views:

123

answers:

2

I am using SF 1.2.9 (with Propel ORM), to build a website. I have generated admin modules for some of my models. I want to modify the template used to display the Form because there are some fields that I dont want to display (but need) - example the 'slug' field in a form.

Since the templates are autogenerated, I cant make the changes there. How can I specify a template to use for rendering a form in the new/edit view?

+2  A: 

In general, to override generated templates with your own, you just have to name your template same as generated one.

But looks like you do not need it. Hint: you can choose which fields to show in admin generator. Please consult symfony reference manual to realize how

develop7
Your link does not work for me thats why I post it here again: http://www.symfony-project.org/reference/1_2/en/06-Admin-Generator#chapter_06_form
Felix Kling
@Felix: can't imagine why a link couldn't work, but fixed anyway
develop7
Thanks guys, I am reading up on the links you posted now. I have managed to change the template, I am now looking at modifying (adding custom logic) to the action for new/edit, using similar logic. If that works, I will accept this as the answer to this problem
Stick it to THE MAN
A: 

To hide or remove fields from a form, I think you should check that link.

To sum up, the admin generator uses a ORM sfForm to render the edit action. So if you remove fields:

// lib/form/doctrine/ADoctrineClassForm.class.php
class ADoctrineClass extends BaseADoctrineClass
{
  public function configure()
  {
    ...
    unset($this['field_name']
    ...

You can also change the widget used the render the field by redefining which widget to use:

//in ADoctrineClass configure method also
$this->widgetSchema['a_field_a_want_to_hide'] = new sfWidgetFormInputHidden()

I hope this helps.

saadou