|
PITS /
00792Summary: Add ability to pre-fill "textarea" input control with a value
Created: 2006-08-24 13:44
Status: Discussion
Category: Feature
From: Pm
Assigned:
Priority: 554444 33
Version: 2.1.14
OS:
Description:
Currently the The primary stumbling block at the moment is having a good markup for it. Suggestions welcomed below. Votes welcomed above. Pm In UpdateForm I implemented this with the same value= markup that the other form tags use, for example (:update type=textarea name=fieldname value="default text":) or just (:update textarea fieldname "default text":) Users need not know that the <textarea> HTML tag has no value parameter; all that matters is that the (:input:) tag has one! Ben Stallings August 24, 2006, at 05:02 PM The downside of this is that it doesn't allow multi-line content for the pre-filled textarea, and since half the point of having a textarea is that it uses multi-line input, I don't think it quite fits the bill. Kathryn Andersen August 24, 2006, at 05:43 PM Does it not allow multiple lines using \\? (Simple tables do - so it's worth trying, if you haven't.) - TeganDowling
From the mailing list: [1] [2] It should be at least possible to pre-fill the textarea from a script/recipe with the $InputValues array. --Petko January 25, 2007, at 04:13 AM Currently the markup (:input textarea value="[= The text here... =]":)or even (:input textarea:)[= The text here... =] just like in The problem is also similar to the great new Page text variables, what if a Ok, here is what I am using currently:
Markup('textarea', '>{$var}',//, '>input'
'/\\(:textarea\\s*(.*?):\\)(.*?)\\(:textareaend:\\)/esi',
"FmtTextArea(\$pagename,PSS('$1'),PSS('$2'))");
function FmtTextArea($pagename, $args, $value)
{
global $InputValues;
$opt = ParseArgs($args);
$attributes = array('name', 'id', 'class', 'rows', 'cols', 'maxlength', 'accesskey', 'disabled', 'readonly', 'style');
$myattr = "";
foreach($attributes as $k){if(isset($opt[$k])) $myattr.=" $k=\"".htmlspecialchars($opt[$k])."\"";}
if(!strlen($value))$value = htmlspecialchars(@$InputValues[@$opt['name']]);
return Keep(FmtPageName("<textarea $myattr>$value</textarea>", $pagename));
}
(:textarea name=area1 cols=40 rows=4 class=inputbox:)Some text New line.(:textareaend:) It is more importanly possible to pre-populate the content from a script/recipe with the $InputValues array (I am using it this way). Hope this helps somebody. --Petko February 24, 2007, at 06:43 AM (Now added to Cookbook.Textarea. --Petko) |