Cliff, you alluded that this doesn't work, but it's actually a valid
signature and should work:

IS_IN_DB(db(db.categories.parent_table==request.args(0)),'categories.id','
categories.name')

just as valid as the following signatures:
IS_IN_DB(db(db.categories.parent_table==request.args(0)), "categories.id",
db.categories._format) #uses the default format of the source table
IS_IN_DB(db(db.categories.parent_table==request.args(0)), "categories.id",
"%(name)s")
IS_IN_DB(db(db.categories.parent_table==request.args(0)), db.categories.id,
"%(name)s")

The OP didn't state what the error was, but there's a typo in his
validator: "c ategories.name" when it should've been just "categories.name".
 Could that be the problem?


On Wednesday, November 23, 2011, Cliff wrote:

> signature from book:
> IS_IN_DB(db, 'person.id', '%(name)s', zero=T('choose one'))
>
> can also be:
> IS_IN_DB(db(query), 'person.id', '%(name)s', zero=T('choose one'))
>
> You have:
> IS_IN_DB(db(db.categories.parent_table==request.args(0)),'categories.id
> ','c
> ategories.name')
>
> Should be:
> IS_IN_DB(db(db.categories.parent_table==request.args(0)),'categories.id
> ','%
> (name)s')
>
>
>
>
> On Nov 21, 10:17 am, tsvim <ttm...@gmail.com <javascript:;>> wrote:
> > Ok, now that this works seems I'm still in trouble.
> > The page I'm loading is one that has a table that I'm trying to make
> > clickable and a form to enter more data.
> > Here is the controller:
> >
> > @auth.requires_login()
> > def budget():
> >     db.expense.parent_table.default = request.args(0)
> >     db.expense.category.requires =
> > IS_IN_DB(db(db.categories.parent_table==request.args(0)),'categories.id','c
> ategories.name')
> >     form = crud.create(db.expense)
> >     expenses = db(db.expense.parent_table==request.args(0)).select()
> >     return dict(user=auth.user.first_name, expenses=expenses, form=form)
> >
> > def edit_expense():
> >     return repr(request.vars.id)
> >
> > My view:
> > <table>
> >   <tr>
> >     <th>Date and Time</th>
> >     <th>Title</th>
> >     <th>Category</th>
> >     <th>Amount</th>
> >     <th>Source</th>
> >   </tr>
> >
> >   {{ for expense in expenses: }}
> >
> >   <tr class="expenses"
> >       id="{{=expense.id}}"
> >       onmouseover="jQuery(this).attr(style.backgroundColor='lightgrey')"
> >       onmouseout="jQuery(this).attr(style.backgroundColor='white')"
> >   >
> >     <td>{{=expense.datetime}}</td>
> >     <td>{{=expense.title}}</td>
> >     <td>{{=expense.category.name}}</td>
> >     <td>{{=expense.amount}} {{=expense.denomination}}</td>
> >     <td>{{=expense.source}}</td>
> >   </tr>
> >   {{pass}}
> > </table>
> >
> > <hr />
> >
> > {{=form}}
> >
> > <script>
> > $(document).ready(function () {
> >      $('.expenses').click(function(){
> >           ajax('edit_expense?id=' + $(this).attr('id'), [], '#target')
> >      });});
> >
> > </script>
> >
> > <div id="target"></div>
> >
> > I added the AJAX script to have it return to edit_expense the id of the
> row
> > that was clicked but I get an error about the crud.create line in my
> > controller.
> >
> > Thanks again for your help.
> >
> > Tsvi
>

Reply via email to