>> > On Jan 1, 9:48 am, pihentagy <pihent...@gmail.com> wrote:
>> > The sytnax is Field(name, type). The default type is a string. If you
>> > want it to be a reference it has to said explicitly. You do the same
>> > in Django. The validator is optional and, in fact, since 1.74 you get
>> > that validator by default if web2py knows how to represent a partner.
>> > For example
>>
>> >     db.define_table('partner',Field('name'),format='%(names)s')
>> >     db.define_table('whatever',Field('partner',db.partner))
>>
>> Hm so getting referential integrity only when the system can _display_
>> some type of record? Again, I see a problem here: validator should
>> really care about validity, and representation should be another
>> thing.
>
> I am not sure I understand. Field('partner',db.partner) defined a
> reference field. The reference is always implemented using the Primary
> Key (the ID field) and this has nothing to do with representation. The
> format string is used only when building a representation of the
> reference in forms. What you see (%(name)s) is not the key and is not
> what is stores in the database for whatever.partner.

Ah, maybe the fact, that I use sqlite for testing purposes can explain things.
So, if I say:
db.define_table('whatever',Field('partner',db.partner))

than, using the appadmin, I can create a record with arbitrary partner
id (because no selectbox for FK selection). And since sqlite does not
handle referential integrity, it can save it fine.

>> And if we are representation: if web2py renders a mandatory FK as a
>> combobox, there is no dummy 'please select one' option.
>> The first valid option is selected by default. This causes serious
>> usability issues, because users will not pay any attention to select a
>> valid option, because there is something, and it validates.
>
> Please never assume that something that is not done by default cannot
> be done.
>
> db.whatever.partner.requires.zero="Please Select One"

Ah, thanks. (IMHO that shold be default in the appadmin).

Another feature, that django's admin knows and quite useful: where you
can select an FK, there is a link for creating that type of object
(displays in a popup). So, when you could not find the desired value
in the selectbox, you can create a new option.

--

You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.


Reply via email to