Skip Menu |

This queue is for tickets about the Catalyst-Plugin-AutoCRUD CPAN distribution.

Report information
The Basics
Id: 67797
Status: resolved
Priority: 0/
Queue: Catalyst-Plugin-AutoCRUD

People
Owner: Nobody in particular
Requestors: maxl.mayr [...] aon.at
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 1.110731
Fixed in: (no value)



Subject: Representing database enums using a drop-down box
I was missing a comfortable way to enter values into an enum column within my DBIx/MySQL database, so I added some code to make it work for me, at least. I attached a small patch that adds support for it. I provide an array-ref called list (which contains the enum's possible values) within the extra-attribute of the column. I think this is what the automatic scheme generation tool was doing some time ago. The changes to the Model/Metadata/DBIC.pm file include the extra-attribute within the column description available to the View and change the extjs_type to 'combo' for an enum column. The changes to the template consider the new extjs_type case. You probably want to take a slightly different and cleaner approach, if you would like to implement this feature yourself. In particular, AutoCRUD will still report that everything is okay even if the user provided an invalid string in an enum field. By the way, AutoCRUD is written in a great and comprehendible way! Keep up the great work!
Subject: enum_support.patch
Plugin/AutoCRUD/Model/Metadata/DBIC.pm 54a55,56 > $xtype_for{'enum'} = 'combo'; > 279a282,284 > > $ti->{cols}->{$col}->{extra} = $info->{extra} > if (exists $info->{extra}); Plugin/AutoCRUD/templates/full-fat/javascript/update/tabs.tt 104a105,115 > [% CASE 'combo' %] > ,store: new Ext.data.SimpleStore({ > fields: [ '[% field %]' ], > data: [ > [% FOREACH option IN info.cols.$field.extra.list %] > ['[% option %]'], > [% END %] > ]}) > ,displayField: '[% field %]' > ,mode: 'local' > ,triggerAction: 'all'
Hi, On Wed Apr 27 14:13:07 2011, desertmax wrote: Show quoted text
> I was missing a comfortable way to enter values into an enum column > within my DBIx/MySQL database, so I added some code to make it work
for Show quoted text
> me, at least.
Many thanks indeed for the patch! This is a good idea. Of course the other way to implement this on the database side without using custom data types would be to have a new table of valid values and a has_one relation to that table - i.e. a foreign key. However it might be nice to offer a simple enum in the configuration (I think Python Django does this :-) I'll take this patch and work something into a future release, hopefully. -- regards, oliver.