0

I'm porting an older Propel and Symfony application that has this form code:

generator:
  class:              sfPropelGenerator
  param:
    model_class:      UserForm
    theme:            default

    config:
      fields:           
        created_at:     { params: date_format='dd.MM.yyyy HH:mm' }
        updated_at:     { params: date_format='dd.MM.yyyy HH:mm' }

      list:
        title:          User Forms
        display:        [=form_name, product_line, created_at, updated_at]
        filters:        [form_name, product_line]
        object_actions: 
          edit:         { label: "Edit", action: "loadForm", icon: "/sf/sf_admin/images/edit.png" }
          _delete:      ~
        actions:
          _new:      ~

However, now that I upgraded to PropelORMPlugin, I no longer see the "edit" button, i.e. the "object_actions" does not seem to work.

This is the only documentation I managed to find https://github.com/propelorm/sfPropelORMPlugin/blob/master/doc/admin_generator.md

Whats the correct way to have "object_actions" in newer version?

Edit: I'm porting from Symfony 1.0 to 1.3, from Propel (I never looked really) to sfPropelORMPlugin.

Tower
  • 98,741
  • 129
  • 357
  • 507

1 Answers1

1

From the documentation:

object_actions:
  moveUp:     { label: "move up", action: "moveUp" }
  moveDown:   { label: "move down", action: "moveDown" }
  _edit:      ~
  _delete:    ~

You should try something like that:

object_actions: 
  edit:         { label: "Edit", action: "loadForm", icon: "/sf/sf_admin/images/edit.png" }
  _delete:      -

By the way, you should precise from wich version you are porting (both propel and symfony).

edit:

They are some difference in the generator.yml file structure between sf 1.0 & sf 1.3+. There is now a level config to put everything. Try with this generator.yml:

generator:
  class: sfPropelGenerator
  param:
    model_class:           UserForm
    theme:                 admin

    config:
      fields:
        created_at:     { params: date_format='dd.MM.yyyy HH:mm' }
        updated_at:     { params: date_format='dd.MM.yyyy HH:mm' }
      list:
        title:          User Forms
        display:        [=form_name, product_line, created_at, updated_at]
        object_actions:
          edit: { label: "Edit", action: "loadForm", icon: "/sf/sf_admin/images/edit.png" }
          _delete: ~
        actions:
          _new: ~
      filters:
        fields: [form_name, product_line]

Few changes to notice:

  • the config: level I've added
  • the _create: become _new:
  • filters goes outside list
j0k
  • 22,600
  • 28
  • 79
  • 90
  • Hmm, interesting. For some reason I see no difference. Do I need to clear the cache and rebuild the forms? I tried, but it made no difference. – Tower Aug 13 '12 at 07:47
  • Could you paste the whole new `generator.yml`? – j0k Aug 13 '12 at 07:48
  • Yes, I've updated the original question. I simply see 6 columns and the data and "New" link on the bottom. – Tower Aug 13 '12 at 08:00
  • I'm a bit confused. If I remove "product_line" from the display list, and clear the cache, it still appears. Looks like none of my changes make any difference and it just goes by default settings. Hmm. – Tower Aug 13 '12 at 08:22
  • Ok, changing theme to "admin" and refresh produced this: `Your generator configuration contains some errors for the "list" context. The following configuration cannot be parsed: array( 'filters' => array( 0 => 'form_name', 1 => 'product_line', ),).`. – Tower Aug 13 '12 at 08:28
  • Oh yep, `filters` is now outside `list`, on the same level of `list`. Updated. – j0k Aug 13 '12 at 08:31
  • Now that that's fixed, I get more errors :) `Fatal error: Cannot instantiate abstract class BaseFormGeneratorConfiguration in C:\www\data\symfony-1.3\lib\generator\sfModelGenerator.class.php on line 429` – Tower Aug 13 '12 at 08:48
  • Are you sure about the `UserForm` in `model_class`, shouldn't be `User` ? – j0k Aug 13 '12 at 08:58
  • Yes it's `UserForm`, like `UserFormPeer`, etc. There's also `User`, but that's not what I want. – Tower Aug 13 '12 at 08:59
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/15256/discussion-between-j0k-and-rfactor) – j0k Aug 13 '12 at 09:07
  • I actually decided to rewrite the forms manually, this is taking so much time. :P – Tower Aug 13 '12 at 09:20