Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using MultipleFileAttachmentField does not create needed ManyManySort field in the database #36

Open
priithansen opened this issue Feb 26, 2012 · 1 comment

Comments

@priithansen
Copy link

After creating the ManyManySort field manually everything seems to work as should.

[26-Feb-2012 05:37:33] Error at sapphire/core/model/MySQLDatabase.php line 525: Couldn't run query:
INSERT INTO "SomePage_MyFiles" ("SomePageID","FileID" , "ManyManySort") VALUES (16, 169 , '1')

Unknown column 'ManyManySort' in 'field list' (http://localhost:8888/ss/admin/EditForm)
[26-Feb-2012 05:39:06] Error at sapphire/core/model/MySQLDatabase.php line 525: Couldn't run query:
INSERT INTO "SomePage_MyFiles" ("SomePageID","FileID" , "ManyManySort") VALUES (16, 169 , '1')

Unknown column 'ManyManySort' in 'field list' (http://localhost:8888/ss/admin/EditForm)

@micahsheets
Copy link
Contributor

ManyManySortable is supposed to work after editing the _config as detailed below. Updates and pull requests since this functionality was added may have broken it however.

  • Adds many_many sortable to a relationship
    • Add the following example to your _config with the
    • The key of the array is the Object that has the many_many relationship set on it.
    • The value is another array in which the 1st element is the Relationship name and the 2nd element is the sort order.
      *
    • Example: ManyManySortable::add_sortable_many_many_relations(array('ParentManyMany' => 'Relationship'));
    • The idea here is that the DataObject that has the many_many relationship is decorated. This way we can add the sorting
    • to the relationship table and not add anyting to the sorted DataObject since this needs to work with File and Image objects
    • instead of creating a new DataObject that has the File as a has_one and decorating that object the way SortableDataObject works.
    • The method ManyManySorted() can be used on the many_many Parent object to get the related Files or Images in the correct order
    • as set in the database in the ManyManySort column.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants