On 24/02/06, Dave Howorth <[EMAIL PROTECTED]> wrote:
> Aaron Trevena wrote:
> > 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.
>
> I agree with you there. Anybody who doesn't is either a saint or a liar
> :) Which is why we have so many individual reworked modules.

Yup.

> > 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
>
> Yup.

This is apparently already happening with the nullable thing of peters
which I'd like to check out properly.

> > * 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
>
> Yup.

Cool - but easier said that done. Currently mostly working in SVN -
need to check edge-cases - Untaint makes it less clear.

> > * Displaying hints for fields
> >   - A required field should be marked as such in a form
>
> That's a nice-to-have.

It would save hours - just being able to check if a field was required
or not, and updating the macros appropriately could save hours.

> > 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');
>
> My FormView uses $class->column_info($col)->{NULLABLE}
>
> I can't remember where I got that idiom from - is it how DBD modules are
> supposed to behave? But in my case I implement the method directly,
> based on my config hashes.
>
> > 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.
>
> Yes, I don't think there's any way I'll go back to CGI::Untaint.

I'd be happy to move to something else if we can provide backward compatibility.

> > 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/);
>
> That's pretty much the information in a DFV profile, in a slightly
> different order.

See - above - I'd love to dump Untaint.

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

Reply via email to