Good morning Martin
I wrote this Saturday night, it uses Moose as both HTML::FormHandler and
Catalyst do... as long as result_source->columns_info gives you what I
think, it should work... beware I only wrote on quick test :)
Hi,
thank you for kickstarting me. I still don't understand there is no such method
provided by DBIx already I have resolved the issue with this diff:
diff -r d65de14e366f lib/reha/Controller/Lesson.pm
--- a/lib/reha/Controller/Lesson.pm Sat Dec 10 17:22:07 2016 +0100
+++
My email coding has some syntax errors, apologies.
On Sat, Dec 10, 2016 at 4:50 PM, LNATION .
wrote:
> and then make a role role
>
> has default_column_spec => ( ...)
>
> before render => sub {
> while (my ($field, $default) = each %{
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);
}
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;
}
}
Also form definition looks like this:
has 'formDetail' => (isa => 'reha::Form::LessonDetail', is => 'rw', lazy => 1,
default => sub {reha::Form::LessonDetail->new });
Is that right in case I would like to have database defaults used after
process()?
Regards
--
M.
On 2016.12.10
Hi Gerda,
sorry for late reply. Didn't have time to look into this.
Now I have:
my $init_row = $c->model('DB::Lesson')->new_result({});
$validated = $self->formDetail->process(item => $init_row);
And I still don't see the database defaults in the rendered form. Any clue
where
A database row is used for defaults only if it is provided in the ‘item’
attribute. If you provide only the item_id and item_class they are used to
update the row but not for defaults.
Gerda
On Mon, Oct 31, 2016 at 12:00 PM, Martin Rehak wrote:
> Hi,
>
> thanks much for
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
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 wrote:
> Am 31.10.2016 um 09:15 schrieb
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,
11 matches
Mail list logo