Page 1 of 1

Using different widgets

PostPosted: Fri Aug 19, 2011 6:37 am
by barryrs
This seems to be something I've run into multiple times.
1. Can I choose which widget to use based on the view? and/or modify the relationship?

ex.
form view of select "TYPE code, Description"
list view of select "TYPE code only"

My solution:
(transaction.php)
function TransactionTypeID__renderCell(&$record)
{ return '<div style="white-space:nowrap">'.substr($record->display('TransactionTypeID'),0,3).'</div>'; }

2. yui_autocomplete Awesome in form view!!!! List view only shows the ClientID number, not the ClientName.
Changing back to select works fine in list. Did I miss something?

I've searched out so many answers to my questions in the forum, thought at least the first part of this might help someone. -Baer

Re: Using different widgets

PostPosted: Sat Aug 20, 2011 2:56 am
by ADobkin
barryrs wrote:2. yui_autocomplete Awesome in form view!!!! List view only shows the ClientID number, not the ClientName.
Changing back to select works fine in list. Did I miss something?


I was actually just working on a similar issue yesterday. And I agree, the yui_autocomplete widget is awesome! (Thanks, Steve!)

However, I don't think the yui_autocomplete widget is appropriate for relationships. I could be wrong, but I think the lookup widget is much better option. You still get a drop-down list of choices, but in this case they are exact matches to the primary key. The yui_autocomplete widget on the other hand allows for arbitrary data to be entered, which would not match to a primary key. I think it is best suited to regular varchar-type fields where arbitrary data is entered but often repeated in other records.

Re: Using different widgets

PostPosted: Mon Aug 22, 2011 1:59 pm
by shannah
form view of select "TYPE code, Description"
list view of select "TYPE code only"


Why not use grafted fields to create different columns. Make one visible in list view and the other visible in form view. By default grafted fields don't show up on the edit form anyways so you only need to worry about hiding one of the fields in list view.

e.g.
Code: Select all
__sql__ = "select t.*, t.TransactionTypeID as TransactionCode from Transactions"

[TransactionTypeID]
    widget:type=select
    visibility:list=hidden
    visibility:find=hidden
    widget:label="Transaction Type"
    vocabulary=TransactionTypeIDs


[TransactionCode]
    widget:label="Transaction Type ID"


or something along those lines.

Re: Using different widgets

PostPosted: Fri Aug 26, 2011 4:52 am
by barryrs
Awesome answer, as always!!! Thank you!!!