-1

I need to edit primary keys in several tables.

By default, symfony hides primary keys in New/Edit forms.

For example, can't edit table 'Tags' with only field 'tag' which is PK. Adding integer ID to this table is not exactly good db design.

Thanks in advance for your help.

olegsv
  • 1,422
  • 1
  • 14
  • 21
  • "Adding integer ID to this table is not exactly good db design." - given that you are now faced with the conundrum of editing the primary key value (and having to cascade those updates across any records that reference that value), I would suggest that perhaps the exact opposite is the case. –  Jan 17 '12 at 22:17

2 Answers2

1

As you say, by "default" symfony hides the primary keys.

As such, you will need to modify the generator.yml to include the specific fields you need, and possibly force the type of the fields to 'text' so they do not render as 'plain'.

If this doesn't work, you can always extend the generator.yml to include pseudo fields for these primary key fields.

As an aside, integer auto-increment primary keys are very useful, and the general feeling is against you :)

Community
  • 1
  • 1
Raise
  • 2,034
  • 1
  • 13
  • 12
  • Even if I open primary key in form class, symfony relies on primary key as editing anchor. Seems to me there is no simple way to implement that. And no, having two separate unique field is not always a good idea when designing a large database. – olegsv May 20 '10 at 10:37
0

As stated by @Raise, the simple solution to this is to create an updatable 'ID' field to work alongside the primary key field which you can leave well alone.

Jon Winstanley
  • 23,010
  • 22
  • 73
  • 116