[pmwiki-users] How do I create a new page from form data?

Paul Bloch paul at cs.uoregon.edu
Mon Feb 3 13:46:27 CST 2014


Thanks for your help.  I did manage to get something working using trial and error.

I have a next set of questions.  I'll give you all my form template to look at.   My questions are all concerning the second form: studentrecordform and studentrecordpost.

1. I have an "input select" that has RecordType values like Admission, Milestone,...  For the Milestone RecordType I need a subtype: RecordSubType.  Is there any way to have that "input select" only show when the RecordType is Milestone?

2. I would like to have different templates in the studentrecordpost based on RecordType.  I tried using "(:if" conditional, but that doesn't get executed in during the post.  The "(if:" gets written to the new page.  Maybe there is a way to set the "fmt=" to a different post record based on the input value.  Then I could have a different template for each fmt post record. 

[[#newstudentform]]
(:input pmform target=newstudent :)
(:template defaults successpage="{*$FullName}" :)
(:input default $:CreationDate {$Today} :)
(:input hidden $:CreationDate :)
(:messages:)
||width='' cellspacing=2
|| First Name:||(:input text $:Firstname :) || Last Name:||(:input text $:Lastname :) ||
|| Grad:||(:input select $:Grad "phd" :) \
   (:input select $:Grad ms :) \
   (:input select $:Grad phd :)
(:input submit :)
(:input end:)
[[#newstudentformend]]

[[#newstudentpost]]
(:template default where=new:)
(:template defaults saveto="GECsis.{$$ptv_Lastname}{$$ptv_Firstname}" :)
(:template defaults savevars=$:Firstname,$:Lastname,$:Grad,$:CreationDate :)
(:template require $:Lastname errmsg="$[Must enter a lastname]" :)
(:template require $:Firstname errmsg="$[Must enter a firstname]" :)
(:template require $:Grad errmsg="$[Must select ms or phd]" :)
(:Firstname::)
(:Lastname::)
(:CreationDate::)
(:RecordType:Main:)
(:Grad::)
(:pagelist group=GECsis name={$:Lastname}{$:Firstname}-*-*  fmt=#titlePlusDate :)
(:title {$:Lastname},{$:Firstname} :)
(:RecordType:Main:)
(:pmform studentrecord:)
[[#newstudentpostend]]

[[#studentrecordform]]
(:input pmform target=studentrecord :)
(:template defaults successpage="{*$FullName}" :)
(:input default $:Lastname {$:Lastname} :)
(:input default $:Firstname {$:Firstname} :)
(:input default $:CreationDate {$Today} :)
(:input hidden $:CreationDate :)
(:messages:)
(:input hidden $:Firstname :)
(:input hidden $:Lastname :)
||width='' cellspacing=2
|| Record Type:||(:input select $:RecordType "Milestone" :) \
   (:input select $:RecordType Admission :) \
   (:input select $:RecordType Milestone :) \
   (:input select $:RecordType Petition :) \
   (:input select $:RecordType AnnualDAC :) \
   (:input select $:RecordType ChangeAdvisor :) \
   (:input select $:RecordType Alumni :)
|| Milestone Type:||(:input select $:RecordSubType "" :) \
   (:input select $:RecordSubType DRP :) \
   (:input select $:RecordSubType OralComp :) \
   (:input select $:RecordSubType Defense :) \
   (:input select $:RecordSubType Dissertation :) \
   (:input select $:RecordSubType Thesis :) 
(:input submit :)
(:input end:)
[[#studentrecordformend]]

[[#studentrecordpost]]
(:template default where=new:)
(:template defaults saveto="GECsis.{$$ptv_Lastname}{$$ptv_Firstname}-{$$ptv_CreationDate}-{$$ptv_RecordType}{$$ptv_RecordSubType}" :)
(:template defaults savevars=$:RecordType,$:RecordSubType,$:Firstname,$:Lastname,$:FormDate :)
(:CreationDate::)
(:Lastname::)
(:Firstname::)
(:Grad::)
(:RecordType::)
(:RecSubType::)
(:title {$:Lastname},{$:Firstname} {$:RecordType} {$:RecordSubType} :)
(:pagelist group=GECsis name=*-{$:Lastname}{$:Firstname} $:RecordType=Main  fmt=#Justtitle :)
%comment%----- Don't edit above this line -------------------------------------------

(:if equal {$$ptv_RecordType} "Admission" :)
* prior degrees:
** BS Major, School, GPA
** MS Major, School, GPA
* GRE (3 numbers)
* Toefl/IESL
* admitted degree at UO: MS or PhD
* assigned advisor
* Note (particular strengths/concerns)
(:ifend:)
(:if equal {$$ptv_RecordType} "Milestone" :)
Milestone
(:ifend:)
[[#studentrecordpostend]]

On Feb 1, 2014, at 1:20 AM, Oliver Betz <list_ob at gmx.net> wrote:

> Paul Bloch wrote:
> 
> [...]
> 
>> * How do I create a page named using these data?
> 
> I used in [[#newuserpost]]:
> 
> |(:template defaults saveto={$$xgroup}.{$$xname} :)
> |(:template defaults successpage="{$$saveto}" :)
> |(:template defaults savevars=...:)
> |(:template require if="!exists {$$xgroup}.{$$xname}" errmsg="Page [[{$$xname}]] exists, use other name":)
> 
> where xname is an input field for the page name. No "saveto" in
> config.php.
> 
> As far as I remember, the documentation was not clear about the
> $$-variable handling. At least, I didn't understand it, my solution
> resulted a bit from guessing.
> 
> I hope this helps as a starting point.
> 
> Oliver
> -- 
> Oliver Betz, Munich http://oliverbetz.de/
> 
> 
> _______________________________________________
> pmwiki-users mailing list
> pmwiki-users at pmichaud.com
> http://www.pmichaud.com/mailman/listinfo/pmwiki-users




More information about the pmwiki-users mailing list