[pmwiki-users] Default form markup questions...

Ben Stallings Ben at InterdependentWeb.com
Thu Aug 24 11:13:44 CDT 2006


Caveman wrote,
> Is there any existing way to use page variables to set default for
> textarea values?
>   
That's one of the minor features I wrote into my UpdateForm recipe... 
you could adapt the code to do the same thing in scripts/forms.php.  
Here are the relevant lines from updateform.php:

toward the top of the script:
# (:update textarea:)
SDVA($UpdateTags['textarea'], array(
  ':html' => "<textarea \$UpdateFormArgs>\$UpdateTextarea</textarea>"));

toward the bottom of the script:
    if ($type=='textarea')
     $FmtV['$UpdateTextarea'] = $UpdateFields[$opt['name']]? 
$UpdateFields[$opt['name']]: " ";

So basically you'd just change all places where it says "Update" to 
"Input" and add $InputTextarea to your list of global declarations in 
the InputMarkup function, and that should do the trick.

Needless to say this is a very useful feature, and I hope to see it 
incorporated in a future version of PmWiki.  ;-)
> Also, on the same subject, are there any alternate markups that allow
> you to set the default values for radio boxes or select boxes without
> having to use an endless bunch of conditionals.
This can also be done with UpdateForm, if you don't mind keeping the 
lists of values in a database... the syntax for a <select> box becomes,
(:update select field_to_save value=id_field label=label_field 
from=lookup_table:)

All the <option> rows are generated automatically and the value that's 
saved in the record you're currently viewing is automatically selected.  
You could set default values for a new record by creating a record in 
the table with a key value of 0 (or "" if your key field is not numeric) 
-- every time the page is loaded with no key specified, it would get the 
default values from the record with the 0 key.

Similarly with radio buttons and checkboxes -- whatever values are saved 
in the record you're viewing are automatically checked... but you do 
have to code each of the radio buttons individually, which can be a pain 
when there are a lot of them.  I haven't figured a good way to generate 
sets of radio buttons automatically.

If you want to incorporate something similar into your FASTdata recipe, 
feel free!  But I think the two recipes should get along pretty well in 
the same installation. --Ben




More information about the pmwiki-users mailing list