Symfony 1.4
Doctrine
admin backend application

With this simplified schema:

Product:
  columns:
    code:       { type: string(10)   }
    name:       { type: string(100)  }
DeliveryRow:
  columns:
    product_id: { type: integer      , notnull: true }
    qty:        { type: decimal(8,2) }
  relations:
    Product:    { onDelete: RESTRICT , local: product_id  , foreign:
id, foreignAlias: DeliveryRows }

I need to have the product name field on the delivery row form, but
the user must not be able to change the product_id value.

I tried this in several ways, but none with the desired result.

1) If I do nothing, I get a product combo in the form. It correctly
shows the product name, but I cannot put the widget in readonly mode.
I can disable it, but this doesn't work, as the validation fails on
save... missing product_id.

2) I tried a readonly text input widget. That works quite well for the
created_at and updated_at fields... but not in this case. If I use it
for the product_id field, it will show the id, and not the product
name. I tried setting it on product_name, product and many other
variations, but it either doesn't work, or I haven't found the correct
way to use that... I just get an empty readonly text input field.

3) I tried a custom field _readonly_product_name, defined in the
generator.yml. I wrote a getReadonlyProductName method in the model.
Again, I just get an empty readonly text input field.

4) I tried using a partial template field. I read that partials gain
automatic access to the current object... so I tried referencing
something like $deliveryRow->getProduct()... $deliveryRow-
>getProduct()->getName()... and many others... I just got a bunch of
undefined variable errors.

5) As a last resort, I was thinking I could embed a special product
form in the delivery form, with just the product name field in
readonly. I haven't tried this one yet, as it seems a bit more
complicated... embedded forms just don't look too right, and I'd have
to work on it a bit to make it look like a field in delivery row main
form.

But I mostly think I just missed something... it wouldn't seem to be
that difficult. Any ideas or pointers (tutorials, howtos)?

TIA and regards,
Marco Rocci

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en

Reply via email to