David,

I'm having some problems with has_many relationships in a number of
places using M:P:FormBuilder.
First of all, the addnew form doesn't seem to add the relationships for
has_many fields.  For example, I have a host table and a ticket table,
and in Host.pm I have:

__PACKAGE__->has_many(tickets => 'MegaPath::Model::Ticket');
sub display_columns { qw(hostname description nms_id monitor sticky
radius_id tickets); }

I found that I had to use display_columns to even get the select box for
tickets to display.  But even so, if I create a host and select tickets
to add to it, it creates the host without the tickets.  Same thing with
the edit form.

Secondly, the addto form is giving me problems with many-many
relationships.  I'm using M:P:Authorize which has a users table, an
auth_role table, and a role_assignment table.  The role_assignment table
is the glue in the many-many relationship, so I have something like this
in User.pm:

__PACKAGE__->has_many(groups => [ MegaPath::Model::Role_assignment =>
auth_role_id ]);
sub display_columns {qw(uid name password groups);}

and in Auth_role.pm

__PACKAGE__->has_many(users => [ MegaPath::Model::Role_assignment =>
'user_id']);
sub display_columns { qw(name users); }


And in Role_assignment.pm:
__PACKAGE__->has_a(auth_role_id => 'MegaPath::Model::Auth_Role');
__PACKAGE__->has_a(user_id => 'MegaPath::Model::User');

So, when I edit the user table, the addto template creates a form for
Auth_role which has the name field and the users select box.  Regardless
of what I select, if anything, in the select box.. the role gets created
but is not associated with the user, or any other user.

I guess my question is..  Is all this stuff known to work?  I noticed
that beerfb.riverside-cms.co.uk is down..  I was hoping I could see an
example of it working, along with the source code. 


On Sat, 2005-09-17 at 18:40 -0700, David Baird wrote:
> On 9/18/05, Daniel Allen <[EMAIL PROTECTED]> wrote: 
> > On 9/17/05, David Baird <[EMAIL PROTECTED]> wrote: 
> >  
> > > I think the docs are out of date. The related() method should
> work 
> > > fine for has_many relationships. Although it's probably broken
> for 
> > > has_a, unless you get the latest from svn. 
> >  
> > Hm, I'm not sure what's out of date in the docs, then- adding the 
> > related() line 
> > from the docs does what he said it should- it associates the beers 
> > table with the 
> > pubs table via the handpumps table... 
> 
> You shouldn't need to add the line, it should work already. If you 
> view a beer, you get a list of its pubs, and vice versa.
> Specifically, 
> there's already a related() method in the model class and it can 
> traverse many-many relationships.
> 
> > But it doesn't provide any means 
> > to add to the handpumps table, does it?  That's really what I'm
> after.
> 
> CDBI would take care of that if there were a multiple select template 
> to provide the interface.
> 
> > I'm finding a bit 
> > of a learning curve with Class::DBI.
> 
> Welcome!
> 
> d.
> 
> 
> ------------------------------------------------------- 
> SF.Net email is sponsored by: 
> Tame your development challenges with Apache's Geronimo App Server.
> Download 
> it for free - -and be entered to win a 42" plasma tv or your very own 
> Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php 
> _______________________________________________ 
> Maypole-users mailing list 
> [email protected] 
> https://lists.sourceforge.net/lists/listinfo/maypole-users
> 


-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
Maypole-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/maypole-users

Reply via email to