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

Hello,

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

Hi willbegood.

Could you describe what you mean by "Admin side"?

Where do you want to view this information?

Thanks,

Jerry Kornbluth
The first CMS Builder reference book is now available on-line!







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

I mean inside cms builder

Re: [willbegood] display a field value as "default value" for a texbox field (admin side)

By gkornbluth - March 15, 2010

sorry but I still don't understand

Jerry
The first CMS Builder reference book is now available on-line!







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

see attachment for what i'm trying to do
Attachments:

image-2.png 157K

Re: [gkornbluth] display a field value as "default value" for a texbox field (admin side)

By willbegood - March 15, 2010

no from the same table. I suppose there is a particular syntax to use, but don't know which one.

Re: [willbegood] display a field value as "default value" for a texbox field (admin side)

By Chris - March 15, 2010

Hi willbegood,

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.
All the best,
Chris

Re: [chris] display a field value as "default value" for a texbox field (admin side)

By gkornbluth - March 16, 2010

Chris,

Thanks for fielding this one.

Jerry
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php