have trnasferred this query here from RDBO group.
Now looking at Role sensitive forms.
I have tried to evaluate this in a simple way: changing the name of a form and seeing what I must do to get this form to 'work'
However despite my best efforts - I can make it sing. The CRUD ecosystem doesnt recognise the form as 'one of its own' and throws errors
I have read other posts here which suggest I may be barking up the wrong tree in that there is a table=form=controller model here and what I am trying to do conflicts with this
I have outlined a simple test case below.
MY TEST:
Create a small database - mine is in postgres 9.1
-- Table: smalltable
-- DROP TABLE smalltable;
CREATE TABLE smalltable
(
id integer NOT NULL,
name character varying(16),
CONSTRAINT pkey PRIMARY KEY (id)
)
WITH (
OIDS=FALSE
);
ALTER TABLE smalltable
OWNER TO postgres;
Create a Catalyst app using these instructions
>>>>>Fixing the errors in the mk_garden script
#!/path/to/perl
use MyDB;
use Rose::DBx::Garden::Catalyst;
my $garden = Rose::DBx::Garden::Catalyst->new(
garden_prefix => 'RDBO',
catalyst_prefix => 'MyDatabase',
controler_prefix => 'MyController'
==========^^^ needs to be double L =============^^^ Need a comma
db => MyDB->new,
debug => 1,
perltidy_opts => '-pbp -nst -nse',
tt => 1,
include_autoinc_form_fields => 0,
column_to_label =>
sub {
my ($garden_obj, $col_name) = @_;
return join(' ', map { ucfirst } split(/_/, $col_name));
},
);
$garden->plant('lib');
Plant the Garden
This now works - OK
JUMP TO HERE IF YOU HAVE WORKING APP
now change the name of Smalldb::SmallTable::Form.pm to be UserForm.pm
Edit
userform.pm - set package to reflect file name UserForm.pm
package RDBO::Smalldb::Smalltable::UserForm;
===================================^^^^^^
edit Controller TestCase::Controller::RDGC::Smalldb::Smalltable.pm
to reflect new form name
package TestCase::Controller::RDGC::Smalldb::Smalltable;
use strict;
use base qw( TestCase::Base::Controller::RHTMLO );
use MRO::Compat;
use mro 'c3';
use RDBO::Smalldb::Smalltable::UserForm;
=======================^^^^^^^
__PACKAGE__->config(
form_class => 'RDBO::Smalldb::Smalltable::UserForm',
===============^^^^^^^^
init_form => 'init_with_smalltable',
init_object => 'smalltable_from_form',
default_template => 'rdgc/smalldb/smalltable/
edit.tt',
model_name => 'RDGC::Smalldb::Smalltable',
primary_key => ['id'],
view_on_single_result => 1,
page_size => 50,
);
1;
Now -try to view a record with this renamed form.
error is
Caught exception in TestCase::Controller::RDGC::Smalldb::Smalltable->auto "RDBO::Smalldb::Smalltable::UserForm is not an object at /usr/local/share/perl/5.14.2/Rose/HTMLx/Form/Related/RDBO/Metadata.pm line 39."