Hi, thanks much for comments.
I know there are number of ways how/where to set/define defaults from app code and there is large text written about it in Catalyst documentation. What I would expect to work at least is that database default is going to be propagated into the form from the schema definition. I don't need to have the second place with explicit default definition when there is and implicit definition coming from db. In other words: $ script/reha_create.pl model DB DBIC::Schema reha::Schema create=static 'dbi:Pg:dbname=<dbname>;host=<host>' reha <pass> generates =head2 capacity data_type: 'integer' default_value: 1 is_nullable: 1 and there is the default definition successfully fetched from db. How to get it used without any override (and duplication) in the app code? Thank you very much in advance. Regards -- Martin On 2016.10.31 09:23:26 +0000, LNATION . wrote: > Probs incorrect approach but it'll work.... > > before render => sub { > unless ($_[0]->field('capacity')->value) { # mayb editing > $_[0]->field('capacity')->value(1); > } > } > > On Mon, Oct 31, 2016 at 8:28 AM, Marc0 <catal...@hidden-primary.net> wrote: > > > Am 31.10.2016 um 09:15 schrieb Marc0: > > > Am 31.10.2016 um 08:57 schrieb Martin Rehak: > > >> has_field 'capacity' => (type => 'PosInteger', > > >> #default => '1', > > >> label => 'Kapacita'); > > > > > > maybe add a "lazy => 1" to your commented "default => '1'"? > > > > > > has_field q(capacity) => ( > > > type => q(PosInteger), > > > lazy => 1, > > > default => q(1), > > > label => q(Kapacita), > > > ); > > > > maybe "capacity" is explicitely set to undef, you could try an "around" > > method modifier to check for a defined value: > > > > has_field q(capacity) => ( > > is => q(ro), # just guessing > > type => q(PosInteger), > > lazy => 1, > > default => q(1), > > label => q(Kapacita), > > writer => q(_set_default_capacity), > > ); > > > > # untested, but according to Moose::Manual::MethodModifiers > > around q(has_field) => sub { > > my $orig = shift; > > my $self = shift; > > > > # check for definedness and set to default value if > > # not defined (NULL) > > $self->_set_default_capacity(1) > > unless defined $self->$orig(); > > > > return $self->$orig(); > > }; > > > > Regards > > -- > > Marc0 > > > > _______________________________________________ > > 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/ > > > _______________________________________________ > 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/ _______________________________________________ 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/