Sorry Long day :) corrected sentence... The problem is because when you call ->new_result the default_value does not get set, which is reasonable behavior the moment you are dealing with time. I am unsure whether there is another create method which uses database or even the schema column spec.
Regards Robert On Sat, Dec 10, 2016 at 5:48 PM, LNATION . <thisusedtobeanem...@gmail.com> wrote: > The problem I think is when you call >new_result the default value from > your database does get **populated that happens when on insert.... > > On Sat, Dec 10, 2016 at 5:17 PM, Martin Řehák <re...@tekkirk.org> wrote: > >> Hi, >> >> I understand that there is a complicated solution. I am looking for >> the simplest way. >> >> Doc says: >> >> <snip> >> For forms where you pass in an 'item' (usually a database row object), >> the values in that object will be used preferentially; if an accessor >> exists in the 'item' object, then the defaults won't be used. (If an >> accessor doesn't exist, the defaults *will* be used.) >> >> $form->process( item => $row, params => {} ); >> >> For the above call the 'default' on the field will not be used, which is >> usually what you want. >> </snip> >> >> What is the easiest way how to get defaults going from the database >> schema into a form, please? Is process() function able to propagate >> defaults from $row into $form? How to achieve that? >> >> Regards >> -- >> Martin >> >> On 2016.12.10 16:51:52 +0100, LNATION . wrote: >> > My email coding has some syntax errors, apologies. >> > >> > On Sat, Dec 10, 2016 at 4:50 PM, LNATION . < >> thisusedtobeanem...@gmail.com> >> > wrote: >> > >> > > and then make a role role >> > > >> > > has default_column_spec => ( ...) >> > > >> > > before render => sub { >> > > while (my ($field, $default) = each %{ >> $_[0]->default_column_spec}{ >> > > unless ($_[0]->field($filed)->value) { # mayb editing >> > > $_[0]->field('$field)->value($default); >> > > } >> > > } >> > > } >> > > >> > > >> > > On Sat, Dec 10, 2016 at 4:41 PM, LNATION . < >> thisusedtobeanem...@gmail.com> >> > > wrote: >> > > >> > >> maybe something like ...... >> > >> >> > >> my $columns = $result->result_source->columns_info; >> > >> my %default_form_spec; >> > >> for my $name (keys %{$columns}){ >> > >> if (my $default = $columns->{$name}->{default_value}) { >> > >> $default_form_spec{ $name } = $default; >> > >> } >> > >> } >> > >> >> > >> >> > >> >> > > >> >> > _______________________________________________ >> > List: Catalyst@lists.scsys.co.uk >> > Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst >> > Searchable archive: http://www.mail-archive.com/ca >> tal...@lists.scsys.co.uk/ >> > Dev site: http://dev.catalyst.perl.org/ >> >> >> _______________________________________________ >> List: Catalyst@lists.scsys.co.uk >> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst >> Searchable archive: http://www.mail-archive.com/ca >> tal...@lists.scsys.co.uk/ >> Dev site: http://dev.catalyst.perl.org/ >> > >
_______________________________________________ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ Dev site: http://dev.catalyst.perl.org/