views:

164

answers:

2

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.

A: 

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 :)

Raise
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.
madkingbilly
A: 

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
I know this solution and I have been using it.Doing DB design right, this is not always a best approach.
madkingbilly
It's only the same as using a code a lá YouTube. Using a code means that the ID is not exposed to users.
Jon Winstanley