display a field value as "default value" for a texbox field (admin side)
9 posts by 3 authors in: Forums > CMS Builder
Last Post: March 16, 2010 (RSS)
By willbegood - March 13, 2010
Let's say i have an editor "person"
Here are my fields that define "person"
name (text field)
age (text field)
description (text box)
I want to set for "descrition" as default value something like that :
"His name is $name and he is $age years old, please call this person"
I want this admin side, i know how to do it with a piece of PHP for a viewer page front side.
I've already tryed to put php code in the default value of my text area... without no result.
Can anybody help?
Re: [willbegood] display a field value as "default value" for a texbox field (admin side)
By gkornbluth - March 15, 2010
Could you describe what you mean by "Admin side"?
Where do you want to view this information?
Thanks,
Jerry Kornbluth
Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php
Re: [gkornbluth] display a field value as "default value" for a texbox field (admin side)
By willbegood - March 15, 2010
Re: [willbegood] display a field value as "default value" for a texbox field (admin side)
By gkornbluth - March 15, 2010
Jerry
Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php
Re: [gkornbluth] display a field value as "default value" for a texbox field (admin side)
By willbegood - March 15, 2010
Re: [willbegood] display a field value as "default value" for a texbox field (admin side)
By gkornbluth - March 15, 2010
Jerry
Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php
Re: [gkornbluth] display a field value as "default value" for a texbox field (admin side)
By willbegood - March 15, 2010
Re: [willbegood] display a field value as "default value" for a texbox field (admin side)
By Chris - March 15, 2010
I don't think PHP alone could solve this, since the name and age fields are on the same web page as the description field. I think the only way to solve this would be with some custom JavaScript which dynamically updates the text field.
A simple alternative might be to literally use "$name" and "$age" in your description field, then replace them on the front-end:
<?php
$record['description'] = str_replace('$name', $record['name'], $record['description']);
$record['description'] = str_replace('$age', $record['age'], $record['description']);
echo htmlspecialchars($record['description']);
?>
If you're set on having the textbox dynamically update, we could accomplish this via custom programming through our consulting service. Please let me know if you're interested in that.
I hope this helps. Please let me know if you have any questions.
Chris
Re: [chris] display a field value as "default value" for a texbox field (admin side)
By gkornbluth - March 16, 2010
Thanks for fielding this one.
Jerry
Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php