Re: [Catalyst] Re: Needs some help with select and Controller::FormBuilder

2008-02-27 Thread Alex Povolotsky

Stephen Sykes wrote:

Alex Povolotsky wrote:

Hello!

I'm trying to make a form with select using Controller::FormBuilder.

Code is quite straightforward



Why not map directly from your model...

$self->formbuilder->field(
name => 'ipid',
options  =>
  [ map { [ $_->ipid, $_->ipaddr ] } $c->model('OurIP')->all ],
);


I've tried to find out if any data is retrieved at all. Yes, they does. 
Why select isn't filled properly?


Alex.


___
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/


Re: [Catalyst] Re: Needs some help with select and Controller::FormBuilder

2008-02-27 Thread [EMAIL PROTECTED]

Kieren Diment wrote:


On 27 Feb 2008, at 08:21, Stephen Sykes wrote:


Alex Povolotsky wrote:

Hello!
I'm trying to make a form with select using Controller::FormBuilder.
Code is quite straightforward
=== edit.fb ===
name: server_edit
method: post
[snip spaghetti]

Why not map directly from your model...

$self->formbuilder->field(
name => 'ipid',
options =>
[ map { [ $_->ipid, $_->ipaddr ] } $c->model('OurIP')->all ],
);



Any chance you can provide a patch to the documentation for 
Catalyst::Controller::FormBuilder for that please?


By the way, my experience is that sometimes people are reluctant to 
provide documentation because they fear ridicule due to their poor 
writing skills. Personally I find that if I write any old crap, then i 
can edit it later, and a blank piece of paper is always more 
intimidating than incoherent ramblings. I promise to edit your 
ramblings if they need it.


___
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/


Might have some time this weekend to write something. I've been working 
with this module within a fairly large web application at my day job, 
for about 95% of all database management functions. I have some nice 
code sniplets I can post, any of which would be extremely useful to 
those starting out with Catalyst::Controller::FormBuilder.


[stephen]

___
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/


Re: [Catalyst] Re: Needs some help with select and Controller::FormBuilder

2008-02-26 Thread Kieren Diment


On 27 Feb 2008, at 08:21, Stephen Sykes wrote:


Alex Povolotsky wrote:

Hello!
I'm trying to make a form with select using Controller::FormBuilder.
Code is quite straightforward
=== edit.fb ===
name: server_edit
method: post
[snip spaghetti]

Why not map directly from your model...

$self->formbuilder->field(
name => 'ipid',
options  =>
  [ map { [ $_->ipid, $_->ipaddr ] } $c->model('OurIP')->all ],
);



Any chance you can provide a patch to the documentation for  
Catalyst::Controller::FormBuilder for that please?


By the way, my experience is that sometimes people are reluctant to  
provide documentation because they fear ridicule due to their poor  
writing skills.  Personally I find that if I write any old crap, then  
i can edit it later, and a blank piece of paper is always more  
intimidating than incoherent ramblings.  I promise to edit your  
ramblings if they need it.


___
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/


[Catalyst] Re: Needs some help with select and Controller::FormBuilder

2008-02-26 Thread Stephen Sykes

Alex Povolotsky wrote:

Hello!

I'm trying to make a form with select using Controller::FormBuilder.

Code is quite straightforward


=== edit.fb ===
name: server_edit
method: post
fields:
   name:
   label: Server Name
   required: 1
   type: text
   size: 60
   descr:
   label: Description
   type: textarea
   rows: 4
   cols: 60
   ipid:
   label: IP
   type: select
   required: 1
=== edit.fb ===

=== from Server.pm ===
sub edit : Local Form {
 my ($self, $c, $lid, $sid) = @_;
 if (!defined $lid) {
   $c->response->redirect($c->uri_for('/location/list'));
   $c->detach();
 }
 my $form = $self->formbuilder;
  my $iplist = $c->model('OurIP')->search(undef,
 {columns =>
  [qw /ipid ipaddr/],
 order_by => 'ipaddr'});
 $c->log->info(join(', ', map { $_->ipid.' '.$_->ipaddr } $iplist->all));
 $form->field(name=>'ipid',
type => 'select',
options =>
[ map { [ $_->ipid, $_->ipaddr] } $iplist->all ],
#other => 1,# create "Other:" 
box  );


# No processing yet
}
=== from Server.pm ===

Looks OK, doesn't it?

Debug shows

[CGI::FormBuilder::Field::select::tag] (debug2) ipid: generating select 
input type
[CGI::FormBuilder::Field::tag_value] (debug2) ipid: called 
$field->tag_value

[CGI::FormBuilder::Field::tag_value] (debug2) ipid: sticky && ! force
[CGI::FormBuilder::Field::cgi_value] (debug2) ipid: called 
$field->cgi_value
[CGI::FormBuilder::Field::tag_value] (debug2) no cgi found, returning 
def_value
[CGI::FormBuilder::Field::def_value] (debug2) ipid: called 
$field->def_value

[CGI::FormBuilder::Field::def_value] (debug2) ipid: def value = ()
[CGI::FormBuilder::Field::inflate_value] (debug2) ipid: called 
$field->inflate_value
[CGI::FormBuilder::Field::select::tag] (debug2) optval(ARRAY(0x94cfd54)) 
= (,-select-,)
[CGI::FormBuilder::Field::select::tag] (debug2) optval(ARRAY(0x94b27fc)) 
= (1,88.212.221.66,)
[CGI::FormBuilder::Field::select::tag] (debug2) optval(ARRAY(0x94335cc)) 
= (23,88.212.221.67,)
[CGI::FormBuilder::Field::select::tag] (debug2) optval(ARRAY(0x94b2b68)) 
= (24,88.212.221.68,)
[CGI::FormBuilder::Field::select::tag] (debug2) optval(ARRAY(0x94b2bb0)) 
= (26,88.212.221.69,)
[CGI::FormBuilder::Field::select::tag] (debug2) optval(ARRAY(0x94a3eec)) 
= (31,88.212.221.71,)
[CGI::FormBuilder::Field::select::tag] (debug2) optval(ARRAY(0x94a3f04)) 
= (28,88.212.221.72,)
[CGI::FormBuilder::Field::select::tag] (debug2) optval(ARRAY(0x94a3fc4)) 
= (27,88.212.221.73,)
[CGI::FormBuilder::Field::select::tag] (debug2) optval(ARRAY(0x94b2010)) 
= (30,88.212.221.74,)
[CGI::FormBuilder::Field::select::tag] (debug2) optval(ARRAY(0x94b2070)) 
= (2,88.212.221.75,)
[CGI::FormBuilder::Field::select::tag] (debug2) optval(ARRAY(0x94b2088)) 
= (29,88.212.221.76,)
[CGI::FormBuilder::Field::select::tag] (debug2) optval(ARRAY(0x94b2100)) 
= (3,88.212.221.77,)
[CGI::FormBuilder::Field::select::tag] (debug2) optval(ARRAY(0x94b213c)) 
= (4,88.212.221.78,)
[CGI::FormBuilder::Field::select::tag] (debug2) optval(ARRAY(0x94334f4)) 
= (5,88.212.221.79,)
[CGI::FormBuilder::Field::select::tag] (debug2) optval(ARRAY(0x94b2160)) 
= (17,88.212.221.81,)
[CGI::FormBuilder::Field::select::tag] (debug2) optval(ARRAY(0x94b21b4)) 
= (6,88.212.221.82,)
[CGI::FormBuilder::Field::select::tag] (debug2) optval(ARRAY(0x94b22b0)) 
= (10,88.212.221.83,)
[CGI::FormBuilder::Field::select::tag] (debug2) optval(ARRAY(0x94b22e0)) 
= (11,88.212.221.84,)
[CGI::FormBuilder::Field::select::tag] (debug2) optval(ARRAY(0x94b22f8)) 
= (12,88.212.221.85,)
[CGI::FormBuilder::Field::select::tag] (debug2) optval(ARRAY(0x94b231c)) 
= (13,88.212.221.86,)
[CGI::FormBuilder::Field::select::tag] (debug2) optval(ARRAY(0x94b279c)) 
= (7,88.212.221.88,)
[CGI::FormBuilder::Field::select::tag] (debug2) optval(ARRAY(0x94b2ab4)) 
= (8,88.212.221.89,)
[CGI::FormBuilder::Field::select::tag] (debug2) optval(ARRAY(0x94a367c)) 
= (25,88.212.221.90,)
[CGI::FormBuilder::Field::select::tag] (debug2) optval(ARRAY(0x94b25a4)) 
= (21,88.212.221.92,)
[CGI::FormBuilder::Field::select::tag] (debug2) optval(ARRAY(0x94b25e0)) 
= (14,88.212.221.93,)
[CGI::FormBuilder::Field::select::tag] (debug2) optval(ARRAY(0x94b2040)) 
= (16,88.212.221.94,)
[CGI::FormBuilder::Field::select::tag] (debug2) optval(ARRAY(0x94b2358)) 
= (9,88.212.221.95,)
[CGI::FormBuilder::Field::select::tag] (debug2) ipid: generated tag = 


 -select-
 88.212.221.66
 88.212.221.67
 88.212.221.68
 88.212.221.69
 88.212.221.71
 88.212.221.72
 88.212.221.73
 88.212.221.74
 88.212.221.75
 88.212.221.76
 88.212.221.77
 88.212.221.78
 88.212.221.79
 88.212.221.81
 88.212.221.82
 88.212.221.83
 88.212.221.84
 88.212.221.85
 88.212.221.86
 88.212.221.88