Good evening,
Sorry for taking so long to get back to this; had to find time
to investigate it more.
On 2/09/10 at 9:50 PM +0100, Carl Franks <fireart...@gmail.com> wrote:
On 26 August 2010 18:02, Charlie Garrison <garri...@zeta.org.au> wrote:
I've got a read-only field (from HTML::FormFu::Model::DBIC) which is losing
the displayed value after form is submitted. I've tried various combinations
of force_default, retain_default, etc but don't seem to be able to get the
right configuration.
Hi,
Sorry, I'm not clear on exactly what behaviour you're seeing, and what
you're expecting - can you clarify?
I'm using a field of type Label to display field/value for
current record, eg:
elements:
- type: Label
name: username
label: User Name
When the form first loads `$form->model->default_values($user)`
the username is displayed as expected in the html page. After
submitting the form, the username is blank in the html page.
All other fields in the form get saved to the db as expected. Am I doing
something wrong in the config or controller action?
Are you expecting the read_only field value to be saved to the database?
No, I'm expecting the form field defined as type Label to retain
it's value after a form submission.
All the read_only option does is cause update/create to not update the
column corresponding to that field.
In the most basic use, it doesn't need force_default or retain_default
to be set - so can you explain what you're wanting that to do?
Hopefully I've clarified above what I'm wanting. I've figured
out why the Label field is losing its value. But I'm not sure
how to fix it or how I should be using FormFu instead.
The cause of the problem is simple, there is no `username` value
being submitted with the form since there is no html <input
type=hidden> for the Label field. The form is populated with
submitted data which doesn't contain the username, so therefore
username appears blank.
I tried creating a Hidden field type named `username`, but I get
the following error when submitting the form:
Can't locate object method "delete_nested_hash_value" via
package "HTML::FormFu" at
/Library/Perl/5.8.8/HTML/FormFu/Element/Label.pm line 77.
I'm guessing that is due to two elements with the same name.
It's quite likely I've got the wrong config/setup, but I'm not
sure what I should be doing. The only solution I've thought of
is to set the default_value for `username` field regardless of
whether the form has been submitted. That doesn't seem like the
right solution though. Would changing the Label element to
optionally include a hidden field be a workable solution?
To simplify this issue, is there a 'correct' way to display a
static/read-only value (eg. Label element) which is retained
after submitting a form?
Charlie
--
Ꮚ Charlie Garrison ♊ <garri...@zeta.org.au>
O< ascii ribbon campaign - stop html mail - www.asciiribbon.org
〠 http://www.ietf.org/rfc/rfc1855.txt
_______________________________________________
HTML-FormFu mailing list
HTML-FormFu@lists.scsys.co.uk
http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu