[SOLVED] Form Introduction | Sourcer + 3 EXAMPLES

marcq

Member
Hi,

I would like to display a table with some information into the "Introduction" field of the form.

I have tried several method but the output is always returning me :

upload_2017-1-14_13-55-23.png

I've tried with | without echoing the html tags, for example

HTML:
echo "<table cellpadding='5%'>";
    echo "<tr>";

I'm declaring the variables with placeholders :

PHP:
$ce_nom ='{gprh_fabrik_user_registration___ce_nom}';
$ce_zip = '{gprh_fabrik_user_registration___ce_zip}';
$ce_city = '{gprh_fabrik_user_registration___ce_city}';

etc.

Would appreciate some help here.

Thanks in advance, cheers, marc
 
You can't use code (as long as you don't have something like sourcerer), it's only for text.
But you can use the element placeholders.

If you want to insert HTML code manually you must switch the editor to HTML mode.
So
a) insert a table via the editor function and "fill" the cells with your element placeholders
or
b) switch to HTML mode and insert directly something like
<table>
<tr>
<td>{placeholder}</td>....

BTW: you can define different intros for new records, form view, details view by doing

Some general text with {element-placeholer}
{new: some text [some-element-placeholder] some more...}
{edit: some text [some-element-placeholder] some more...}
{details: some text [some-element-placeholder] some more...}

inside these switches the element placeholders need [] instead of {}
 
Thanks troester I'm looking into it and I'll confirm you that it is working.

I have a strange issue perhaps you could try to reproduce it on the last version.

I wanted to have all elements of a form group not being displayed in list view, so I choose the form, the group, checked all elements of this group and clicked on " Supprimer de la liste" thinking that the "Afficher dans liste" button would be unpublished for all those elements.

But instead the whole group including its elements where deleted. I have checked the trash etc. ano group and no elements anymore.

Since I haven't update the last github and I'm still working wiyh Fabrik 3.5.1 it would be perhaps good to check your last version.

In the mean time I will load my last database dump.

cheers, marc
 
But instead the whole group including its elements where deleted. I have checked the trash etc. ano group and no elements anymore.
This sounds very strange.
You've done this in the element listing?
If you accidentially hit Trash the elements would show up in the trash.
Are you sure your you had not selected the filter (bottom left side) Show in list = yes?
 
I'm sure troester, I have of course checked the trash and it is empty, all the 15 elements and the group seems to have been deleted. As you say if I had accidentaly hit the trash button I would find them in the trash which is not the case. The only way to delete definitively an element is to trash it and after to empty the trash and I'm 100 % certain that I haven't trashed anything and empty the trash.
 
I tried to replicate but was unable to reproduce the same error. Would never know what happened. Thank you anyway for your support troester
 
Hi troester, concerning adding an html table into the intro field of a form, it is working well, thank you.|

I just have a problem with a date which is displayed as follows :

Code:
2016-06-15 16:54:29

I would like to display this date as follows in my table :

Code:
lundi 12 janvier 2017

So I defined the Form format of the date element as follows :

Code:
l d F Y

Screenshot : please see "Date d'adhesion" :

upload_2017-1-15_21-16-38.png

Thanks in advance for your support.

Cheers, marc
 
I wanted to have all elements of a form group not being displayed in list view, so I choose the form, the group, checked all elements of this group and clicked on " Supprimer de la liste" thinking that the "Afficher dans liste" button would be unpublished for all those elements.

But instead the whole group including its elements where deleted. I have checked the trash etc. ano group and no elements anymore.

I've never seen this happen, either to me, or to anyone else, in ten years of working with Fabrik. So I really don't know what might have happened. And if you can't replicate it, we'll just have to file it under "very strange, probably won't ever happen again".

-- hugh
 
Maybe the element placeholder is using the date list format.

When rendering a form, the data being used for placeholders in the intro/outro is as it came out of the database, it has no "formatting". You still have raw and non-raw versions, so things like joins will have their labels, but none of the actual per-element formatting for form display is there. That's done in the element rendering phase, and that rendered data is never actually stored in $formModel->data[] (the data array we use for those placeholders), it's stored in the separate group/element structure that holds all of the rendering data.

If you really want that date formatted, you'd have to do it with something like Sourcerer, and format it yourself. We do our placeholder replacement in the intro/outro before we run the text through the J! content plugin handler, so that should work.

Code:
{source}
<?php

try
{
    $myDate = new DateTime('{yourtable___yourdate}');
}
catch (Exception $e)
{
    echo "invalid date";
}

echo $myDate->format('I d F Y');

?>
{/source}

Note the try/catch in there, in case the date isn't a valid date string (like the element has no value). You can get rid of the echo "invalid date", and just do nothing. Without that try/catch it'll throw an error.

-- hugh
 
Hi Hugh,

Thanks for your tip. I tried sourcerer which is working well into an article (I could echo a message without any issue), but not into the fabrik introduction field.

Php is not stripped into Joomla articles, but is stripped into the fabrik introduction field :

Code:
{source 0}<!--?php

try
{
    $myDate = new DateTime('{gprh_fabrik_user_registration___date_membership}');
}
catch (Exception $e)
{
    echo "invalid date";
}

echo $myDate-&gt;format('I d F Y');

?-->{/source}

I have tried with [[ instead of < and ]] instread of > as Regular Labs faq propose to do if tags are stripped, but it is still not working since the whole code is displayed in :

Code:
[[?php try catch (Exception $e) echo $myDate->format('I d F Y'); ?]]

Any clue Hug where te problem could be ?
 
Hi Hugh,
Sorry to bother you with this, but it seems that sourcer is not working in the form introduction. Is it a known issue ?
the 2 sourcer plugin are published, right are set to Super Administrateur GPRH which have access to the form in which I want to display the data with sourcer.
Thanks in advance for your time.
Cheers, marc
 
Hereafter examples of what you can do with sourcerer :

If else if loop
Code:
{source} [[?php $civilite = '{gprh_fabrik_user_enrollment___civilite_raw}'; if ($civilite == "1") { echo 'Madame'; } else if ($civilite == "2") { echo 'Mademoiselle'; } else if ($civilite == "3") { echo 'Monsieur'; } else if ($civilite == "0") { echo 'Non renseign?'; } else {}; ?]] {/source}

Date formating
Code:
{source} [[?php setlocale (LC_TIME, 'fr_FR.utf8','fra'); $date = '{gprh_fabrik_user_enrollment___date_time}'; echo utf8_encode(strftime("%d-%m-%Y",strtotime($date))); ?]] {/source}

Query are also working well
Code:
{source} [[?php $candidateid = '{gprh_fabrik_user_enrollment___id}'; $db = JFactory::getDbo(); $query = $db->getQuery(true); $query ->select (array('gprh_fabrik_user_enrollment.id', 'gprh_fabrik_user_training.intitule', 'gprh_fabrik_user_training_124_repeat.nom_formation', 'gprh_fabrik_user_training_124_repeat.intitule_session', 'gprh_fabrik_user_training_124_repeat.intitule_prix')) ->from('gprh_fabrik_user_enrollment') ->leftJoin('gprh_fabrik_user_enrollment_repeat_choix_formation ON gprh_fabrik_user_enrollment.id = gprh_fabrik_user_enrollment_repeat_choix_formation.parent_id') ->leftJoin('gprh_fabrik_user_training_124_repeat ON gprh_fabrik_user_enrollment_repeat_choix_formation.choix_formation = gprh_fabrik_user_training_124_repeat.id') ->leftJoin('gprh_fabrik_user_training ON gprh_fabrik_user_training_124_repeat.parent_id = gprh_fabrik_user_training.id') ->having('gprh_fabrik_user_enrollment.id = ' . $db->quote($candidateid)) ->group('gprh_fabrik_user_enrollment.id, gprh_fabrik_user_training_124_repeat.nom_formation, gprh_fabrik_user_training.intitule'); $db->setQuery($query); $row = $db->loadObjectList(); echo "
"; foreach ($row as $item) { echo $item->nom_formation; echo " | "; echo $item->intitule_session;; echo " | "; echo $item->intitule_prix; } echo "
"; ?]] {/source}
 
Yes, Sourcerer is a powerful tool, and can be used to good effect in combination with the "process J! plugins" feature in Fabrik.

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top