Jump to content

Add String to the Field Dynamically


SIERRA
 Share

Recommended Posts

Hi,

  1. We have 'Seminar_Schedule' repeater field in the template (One of the Admin Control Panel Page)
  2. Inside the 'Seminar_Schedule' repeater field, we have 'preview_sms_content' field and other fields.

In this 'preview_sms_content' field (textarea) -

  • How to add our SMS Content to this field dynamically. (Based on the values entered on the other input fields)
  • How to display the characters count of SMS Content to this field dynamically.
  • How to restrict to enter the characters manually.(How to make this field readonly)

PFA and Suggest,

Thank you

 

Screenshot_262.png

Link to comment
Share on other sites

If this content is not editable you could use FieldtypeCache (a core module) and FieldtypeRuntimeOnly. Create a FieldtypeCache field “sms” and select the fields you would like to combine under the “Details” tab. Create a FieldtypeRuntimeOnly field “preview_sms_content” (instead of your textarea) and edit the associated php file to have something like:

if(empty($page->sms)) {
	return "No content yet";
} else {
	$sms = implode(" ", $page->sms);
	return "$sms (" . strlen($sms) . " characters)";
}

Add both fields to your repeater, save and you should see the SMS preview.

Edit: actually you could skip the FieldtypeCache and just concatenate your strings in the FieldtypeRuntimeOnly php file...

Edited by monollonom
  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...