Hi Carl,

From: "Carl Franks" <fireart...@gmail.com>
2009/1/12 Octavian Rasnita <orasn...@gmail.com>:
Hello,

In a Catalyst Controller I've tried to create a new row using:

$form->model->create({hash => $hash});

I normally call $form->model->create() without any args.
If you provide an argument, it should just be interpreted as a
hash-ref of attributes to modify create's behaviour, and never be
passed to the database, so I'm not sure what's happening here.

I've re-read the POD docs and now I see that I didn't understand correctly.
I had previously done:

my $hash = sha1_hex($username . $email . time());

my $new_user = $c->model("DB::TempUser")->new_result({hash => $hash});
$form->model->update($new_user);

And I thought that I could add that new field in the database as a parameter of create(), without needing to use the new_result() method of DBIC.

Furthermore, the error message is confusing, because the printed SQL
statement doesn't mention a 'hash' field anywhere.

Of course it doesn't print the hash field, because if the create() method doesn't accept new fields... there is no a hash field in the form.

I was confused because some time ago, for creating a new record, I needed to use the new_result() method of DBIC (and then the update() method), and that method could accept new fields, and now the improved and probably recommended way is to use the create() method, without needing to use new_result(), and I thought that it is also possible to add new fields.

Is it possible to add the fields without using:

$form->add_valid(hash => $hash);

What are you expecting the { hash => $hash } to do? or is it just the
final result of lots of troubleshooting? :)
(btw, what does $hash contain? I can't think off-hand if it could
affect things, but it might help)

$hash is a SHA-1 hash that will be sent by email to the user that just created an account.

Thanks.

Octavian


_______________________________________________
HTML-FormFu mailing list
HTML-FormFu@lists.scsys.co.uk
http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu

Reply via email to