X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=ex%2Ffancy_example%2Ftemplates%2Fcustom%2Fdisplay_inputs;fp=ex%2Ffancy_example%2Ftemplates%2Fcustom%2Fdisplay_inputs;h=6baf703c7acb546588fba45696575704c3075bc2;hb=e1ed80e9b0929d184fabfb6d4df9a8db4580eb4e;hp=201227ccf9803716ef4474de034cf151e92e398e;hpb=833895f46fdd117b0416acff264041af2ce6f46a;p=maypole.git diff --git a/ex/fancy_example/templates/custom/display_inputs b/ex/fancy_example/templates/custom/display_inputs index 201227c..6baf703 100644 --- a/ex/fancy_example/templates/custom/display_inputs +++ b/ex/fancy_example/templates/custom/display_inputs @@ -32,18 +32,25 @@ values on errors FOR c IN request.config.$tbl.required_cols; required.$c = 1; END; + %] -[% FOR col = classmetadata.columns; +[% +SET heading_shown = 0; +FOR col = classmetadata.columns; NEXT IF !classmetadata.cgi.$col; NEXT IF col == "id" OR col == classmetadata.table _ "_id"; - # Display foreign inputs last IF (mykeys = classmetadata.cgi.$col.keys); foreign.push(col); names.push(classmetadata.colnames.$col); NEXT; END; + IF ! heading_shown; + heading = classmetadata.moniker | ucfirst; + "

$heading

"; + SET heading_shown = 1; + END; %] [% # Base case starts here @@ -84,9 +91,19 @@ values on errors [% USE this = Class(classmetadata.name); FOR col IN foreign; - fclass = this.related_class(request, col); + # has_many mapping throws a stick in our spokes because related_class returns the mapped + # class. Sometimes we just want the has_many class. + + # In case of Pub Handpumps maps to Beer and we want to add Handpump to Pub, we dont + # want the mapped data . + # In case of "Create New Handpump" -- we want the mapped data probably so we get + # Beer inputs and Pub select box. + + fclass_rel_meta = this.related_meta(request, col); + fclass = fclass_rel_meta.foreign_class; # ignor args.mapping fclass_meta = this.get_classmetadata(fclass); - fclass_meta.cgi = classmetadata.cgi.$col; + fclass_meta.cgi = classmetadata.cgi.$col; + # USE Dumper; Dumper.dump(fclass_meta); INCLUDE display_inputs col_prefix = col _ "__AF__" _ col_prefix errors = errors.$col