Drkcore

31 05 2007 perl catalyst Tweet

Catalyst::Controller::FormBuilder引き続き

引き続きCatalyst::Controller::FormBuilderをいじってるヨ。ってかCGI::FormBuilder読んだ。

で、昨日はこんな感じで書いてたんだけど

my $data = {
            title            => $form->field('title'),
            content          => $form->field('content'),
            tag_text         => $form->field('tag_text'),
            pubdate         => $dt
            };

my $e = $c->model('DBIC::Entries')->update_or_create($data);

でも、podみてたら$form->fieldってメソッド使えばハッシュのリファレンスが返ってくるので、

my $data = $form->field;
my $e = $c->model('DBIC::Entries')->update_or_create($data);

でいいらしい。早速書き直した。フォームのパラメータとかバリデーションとかよきに計らってくれる上に、DBICとの連携も楽だ。

それがDWIMmery?

CGI::FormBuilder - Easily generate and process stateful forms - search.cpan.org

The goal of CGI::FormBuilder (FormBuilder) is to provide an easy way for you to generate and process entire CGI form-based applications. Its main features are:

  • Field Abstraction
  • DWIMmery
  • Built-in Validation
  • Template Support

About

  • もう5年目(wishlistありマス♡)
  • 最近はPythonとDeepLearning
  • 日本酒自粛中
  • ドラムンベースからミニマルまで
  • ポケモンGOゆるめ

Tag

Python Deep Learning javascript chemoinformatics Emacs sake and more...

Ad

© kzfm 2003-2021