Well, self referencing list:reference fields do not get a default
requires but you can add it manually and set the label to your liking:

db.div.child_div.requires = IS_IN_DB(db, db.div, '%(name)s',
multiple=True)


On Oct 16, 1:31 pm, Erwin Pass <[email protected]> wrote:
> Hi,
>
> Thx! Wow, thats a pretty awesome feature! :)
>
> But if I understand you correctly then this "doesn't work" for self
> references. I mean "doesn't work" as "in the same way as for foreign list
> references". Whereas in the latter case a big multiselect box gets
> displayed, only a usual input field (for ids?) is displayed if this
> technique gets applied on self references. Is my understanding correct?
>
> So this would require a custom view implementation on my side...
>
> Thanks again to the list for taking your time to answer my questions
>
> Erwin
>
> 2011/10/15 DenesL <[email protected]>
>
>
>
>
>
>
>
> > Hi Erwin,
>
> > for the second part you could use a list:reference field.
>
> > For presentation purposes you can adapt what was said in
> >http://groups.google.com/group/web2py/msg/b8f9518487df1b9b
>
> > On Oct 15, 9:05 am, Erwin Pass <[email protected]> wrote:
> > > Hi there,
>
> > > I saw on stackoverflow that you prefer questions here :)
>
> > > I need to display a form for a nested table structure. This means that
> > > a record of a table might have a reference to another record of that
> > > table. I have no idea how to model  something like this using DAL and
> > > SQLFORM. I guess it isn't even possible but  you might have another
> > > idea to implementi this.
>
> > > To illustrate my problem  think about some xml or html structure where
> > > a node of a certain type can contain nodes of other types as well as
> > > nodes of the same type.
>
> > > <div id='some_div_record'>
> > >     <ul id='root_ul_ref'>
> > >         <li id='first_li_ref'>text</li>
> > >          ...
> > >         <li id='nth_li_ref'>nth text</li>
> > >      <ul>
> > >      <div id='another_div_record'>
> > >          ...
> > >       </div>
> > > </div>
>
> > > A div block might contain other div blocks. This seems not to be
> > > possible to model using DAL:
>
> > > db.define_table('div',
> > >     Field('text', type='string'),
> > >     Field('ul', type=db.ul),
> > >     Field('div', db.div))
>
> > > This attempt results in some KeyError: 'div', probably caused because
> > > db.div is about to defined but referenced before it could be
> > > constructed fully.
>
> > > The second part of the problem I'm facing might be an even tougher
> > > one. Because I not only need to store references to _one_ another
> > > record of the same table but to a unknown number of such records. (It
> > > is not known how many divs the user choses to nest within...)
>
> > > I guess this requires another table like db.div_to_div which contains
> > > the references (ids) but then I'm lost on ideas how to connect
> > > implement the view which connects all this and enables the user to
> > > enter his data.

Reply via email to