On 24/02/06, Dave Howorth <[EMAIL PROTECTED]> wrote:
> Aaron Trevena wrote:
> > Peter and I are working through final documentation and API for forms
> > in Maypole and I was wondering how people would prefer empty fields
> > and required columns to work, at least as far as Untaint. FromCGI and
> > dropdowns in add/edit forms are concerned.
> >
> > Peter's AsForm and Model::CDBI now provide a way to set a column as
> > nullable, and Model::CDBI also checks a per table configuration of
> > required and ignore fields for use with FromCGI.
> >
> > I was thinking of combining these two methods, with a check of
> > required fields if specified, falling back to nullable fields if none
> > specified and/or checking the type with Type::Plugin..
> >
> > Anybody have any preferences - default to required or optional?
>
> I'm having trouble understanding what you're suggesting. Are the docs
> available? - that would be a good way understand the proposal.
The docs aren't really available - it's just that I find it a pain in
the arse to do forms using CGI::Untaint and the current AsForm, with
plain CDBI classes.
Essentially you have several things affected by whether a field is
required or not:
* Foreign Relation Select lists
- These should have a null option, if the field isn't required
* Untainting of a field
- An empty field should not result in an error if the field is not
required but should be validated if present, and should also remove
the value in the database if blank
* Displaying hints for fields
- A required field should be marked as such in a form
The current Maypole::Model::CDBI::AsForm checks if a field is
nullable, based on the examples peter provided in the other progess
thread :
1) checks args->{column_nullable}
$beer->to_field(brewery, {column_nullable => 1, column_default => undef });
2) It tries to call $model->column_nullable
$beer->to_field('brewery');
CGI::Untaint checks if a list of 'required_cols' and 'ignore_cols' are
provided, this is affected by using the untaint command and I want to
look into documenting how this works as it has annoyed me greatly on
my last project and is starting to grate on this one.
I want to be able to say what is required, or not and then it be
handled correctly when displaying and validating forms.
My proposal is being able to specify which columns are required, and
using this information to set everything else.
for example :
MyApp::Job->columns(All => qw/Title Salary FAO Closing_Date
Description Location/);
MyApp::Job->has_a(Location => 'MyApp::Location');
MyApp::Job->untaint_columns(
printable => [qw/Title Salary Description/],
date => ['Closing_Date'],
email => ['FAO'],
integer => ['Location']
);
MyApp::Job->required_columns(qw/Title Salary FAO Closing_Date/);
cheers,
A.
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid0944&bid$1720&dat1642
_______________________________________________
Maypole-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/maypole-devel