Have been trying unsuccessfully to prepopulate a form field with an array.
Have created an array from K2 content elsewhere on site. Looking to pass the array into predefined "Theme" form field within ChronoForms. User should select an item and once arriving to form, field "Theme" is filled in with user selection.
Have tried many different solutions. Unfortunately, form field remains empty.
PHP Code to retrieve K2 Title (Works to populate array):
Screen shots:
1. Show arrays in Custom Code action. Array "[theme] = Generic" is what I need in form field "Theme".
Using this php code in Custom Code action to see arrays at top of form page:
[attachment=0]session.png[/attachment]
2. Field Theme
[attachment=0]theme-field.jpg[/attachment]
Form field code:
Suggestions welcome.
Thanks in advance.
Dave
Have created an array from K2 content elsewhere on site. Looking to pass the array into predefined "Theme" form field within ChronoForms. User should select an item and once arriving to form, field "Theme" is filled in with user selection.
Have tried many different solutions. Unfortunately, form field remains empty.
PHP Code to retrieve K2 Title (Works to populate array):
<?php
$K2Itemid = JRequest::getInt('id');
if($K2Itemid)
{
$db = JFactory::getDBO();
$db->setQuery("SELECT title FROM #__k2_items WHERE id = ".$K2Itemid );
$K2Title = $db->loadResult();
}
?>
Screen shots:
1. Show arrays in Custom Code action. Array "[theme] = Generic" is what I need in form field "Theme".
Using this php code in Custom Code action to see arrays at top of form page:
<?php
session_start();
Print_r ($_SESSION);
?>
[attachment=0]session.png[/attachment]
2. Field Theme
[attachment=0]theme-field.jpg[/attachment]
Form field code:
<div class="ccms_form_element cfdiv_text">
<label for="theme">Theme</label>
<input type="text" name="title" id="K2Title" class="inputbox"
value="<?php echo $K2Title; ?>" />
<div class="clear"></div>
</div>
Suggestions welcome.
Thanks in advance.
Dave