stonecolddevin has asked for the wisdom of the Perl Monks concerning the following question:
UPDATE: Looks like there was some issues with my HTML:
<!--TMPL_INCLUDE name="header.html"--> <p>Sign our guestbook!</p> <form action="" method="post"> <input type="hidden" name="create" value="yes" /> <input type="hidden" name="m" value="sign" /> <-- needed this to post +to the correct run mode <p>Name:<input type="text" name="name" /></p> <p>Email:<input type="text" name="email" /><input type="checkbox" name +="hide_email" /> Hide email</p> <p>Website:<input type="text" name="website" value="http://" /></p> <p>Comments:</p> <p><textarea name="comments" rows="10" columns="45"></textarea></p> <p><input type="submit" name="Post your comment" /></p> </form> <!--TMPL_INCLUDE name="footer.html"-->
Howdy all,
I just started using DBIx::Class, in lieu of Class::DBI basically. Retrieving is going great however I seem to be having some troubles createing.
UPDATE:Apparently I wasn't clear enough when i said that the record wasn't being created at all, there are no error messages being returned, the script just isn't creating a record.
My code is posted below, I think all that is posted is necessary to see the issue, along with the HTML form.
Let me know if you have any ideas...
Code:
sub sign { my $self = shift; my $q = $self->query; my $tmpl = $self->load_tmpl( 'comment.html', %config_vars ); ############################# # cleaning the HTML # we use HTML::Scrubber to clean up the HTML so our code doesn't b +reak use HTML::Scrubber; my $name = $q->param('name'); my $email = $q->param('email'); my $website = $q->param('comments'); my $hide_email = $q->param('hide_email'); my $comments = $q->param('comments'); # let's create an array of the params in this form: my @form_data = ( $name, $email, $website, $comments, $hide_email +); # the HTML::Scrubber object # allow <br /> <p> <b> <i> <u> <hr /> # this will be put into a config file eventually (aka upon product +ion) my $scrubber = HTML::Scrubber->new( allow => [ qw[ p b i u hr br ] + ] ); # deny list # deny <link> <a> *<script>*<- especially, <style> $scrubber->deny( qw[ link a href script style ] ) ; # scrub all the form data passed to this script... $scrubber->scrub( $_ ) for @form_data; ############################## # time to create a new comment... my $comment; if ( $q->param('create') eq "yes" ) { $comment = $schema->resultset('Comments')->create( { name => $name, email => $email, website => $website, comments => $comments, hide_email => $hide_email, } ); $comment->update; return qq{Thank you for your comments! <a href='?'>«back +</a>}; } $tmpl->output unless $q->param('create'); }
HTML(with HTML::Template tags):
<!--TMPL_INCLUDE name="header.html"--> <p>Sign our guestbook!</p> <form action="" method="post"> <input type="hidden" name="create" value="yes" /> <p>Name:<input type="text" name="name" /></p> <p>Email:<input type="text" name="email" /><input type="checkbox" name +="hide_email" /> Hide email</p> <p>Website:<input type="text" name="website" value="http://" /></p> <p>Comments:</p> <p><textarea name="comments" rows="10" columns="45"></textarea></p> <p><input type="submit" name="Post your comment" /></p> </form> <!--TMPL_INCLUDE name="footer.html"-->
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Problems with DBIx::Class and CGI::Application
by grep (Monsignor) on Sep 22, 2006 at 05:12 UTC | |
by stonecolddevin (Parson) on Sep 22, 2006 at 06:07 UTC | |
by grep (Monsignor) on Sep 22, 2006 at 15:33 UTC | |
by Anonymous Monk on Sep 22, 2006 at 20:18 UTC | |
|
Re: Problems with DBIx::Class and CGI::Application
by chromatic (Archbishop) on Sep 22, 2006 at 06:33 UTC | |
by stonecolddevin (Parson) on Sep 22, 2006 at 06:40 UTC | |
|
Re: Problems with DBIx::Class and CGI::Application
by initself (Monk) on Sep 22, 2006 at 05:30 UTC |