Forums

Joomla Custom fields as form data

deltafidesign 31 Aug, 2017
I would like to have a form that automatically shows into the header of the form (into a custom HTML) and also in the email sent some custom fields of the article viewed at the moment when the user submit the form.

For example, in Article 1 I have in the sidebar the form. In the form header I want to display the Article title and also some specific custom fields data of that article, example: date: 31/08/2017 and location: my venue 1

Meanwhile in Article 2 I have always the form in the sidebar. In the form header I want to display the Article title (Article 2 in this case) and also some specific custom fields data of that article, example: date: 03/09/2017 and location: my venue 2.

How to?
GreyHead 31 Aug, 2017
Hi deltafidesign ,

If you can capture the article ID from the page URL - or the Menu ItemID or the article title, then you can use Custom Code and/or DB Read actions after the form submits to look up the other information you need. Please see this FAQ for a bit more info.

Bob
deltafidesign 31 Aug, 2017
Thanks for reply Bob, I've took a look at the guide but I'm not able to do it.

Would you please help me with a step by step example and code I should write?

Thanks in advance
Max_admin 31 Aug, 2017
Hi deltafidesign,

Do you have the latest Chronoforms update ?

Please use a "Read data" action in the "load" event of your form, set the Where conditions to:

id:{data:id}

And the table to ####_content, and the "Select type" to "First matching", then your article data should be available under:
{var:read_data_name.ModelName}, you can use {var:read_data_name.ModelName.title} for example.

Best regards,
Max
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
deltafidesign 31 Aug, 2017
Hi Max,

I've done what you've suggested and checked again and again, but it seems not work for me.

I've created the read data action in the load event and setted as yu suggested. Then I've added to my forum header HTML:
<p>{var:read_data_name.ModelName.title}</p>

But in output I see only <p></p>

What's wrong?
Max_admin 31 Aug, 2017
Hi deltafidesign,

You will need to replace the "read_data_name" with the name of the read data action and the "Modelname" with the model name used.

Best regards,
Max
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
deltafidesign 31 Aug, 2017
UP to my previous post. I've solved this way: <p>{var:read_data6.dati_articolo.title}</p>

Now, how should I write it to get some joomla custom fields instead of the article title?
Max_admin 31 Aug, 2017
Hi deltafidesign,

Please use a debugger action after the read data and you will be have list of all returned fields from the table.

Best regards,
Max
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
deltafidesign 01 Sep, 2017
Hi Max,

this is what I get with the debugger:

This is private content



I don't see any custom field, am I wrigth?
Max_admin 02 Sep, 2017
Hi deltafidesign,

No custom field, but your custom field is in the content table or a different table ? if its in a different table then you will need to make a relationship between the 2 tables, this is available in the "Read data" settings.

Best regards,
Max
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
deltafidesign 02 Sep, 2017
I refer to the new feature of joomla custom fields, those fields are stored in the com_fields component that should refer to the relative table.

How should I make a relationship? any suggestion?
Max_admin 03 Sep, 2017
Hi deltafidesign,

I checked the database, you will need to connect 3 tables, the main content table, and the _fields table + fields_values table.

The content and fields tables can be connected using the "asset_id" field, the fields and fields_values tables can be connected using the id/field_id fields.

You can use the "Relation fields" box when connecting the content and fields tables, something like should work:
Content.asset_id:Field.asset_id

Assuming you use "Content" and "Field" as models names.

And in the 2nd relation you can use the "Foreign key" which should be "field_id".

Best regards,
Max
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
deltafidesign 07 Sep, 2017
Sorry Max,

what "Relation fields" box is? In the Read data action I don't see that box.
Max_admin 20 Sep, 2017
Hi deltafidesign,

Sorry, it the "Relation conditions" after you add a new model, under the new model settings.

Best regards,
Max
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
deltafidesign 21 Sep, 2017
Hi Max,

I'm loosing in this process, can you please help me with a step by step guide. I would really appreciate it. I can't do it. Thanks so much in advance.
pixelhexe 21 Sep, 2017
1 Likes
I just resolved the very similar issue and managed it with two "DB Read actions" - could not find a "relation fields box" either.

One action 1. for the field "title" of table #_content and the
second 2. for a custom field of table #_fields_values.
This custom field values table has the fields 'id', 'item_id' (which is the id of #_content) and 'value'.
@deltafidesign: there you should get your date and location values of your custom fields.

1. Model name "Content", 2. "Buchpreis".
Filtering settings:
1. Where conditions "Content.id:{data:id}",
2. "Buchpreis.item_id:{data:id}"

Data settings - Select type "First matching record" for both.

1. Fields to retrieve "Content.title", 2. "Buchpreis.value"

Finally I can get the values with
{var:read_data5.Content.title}
and
{var:read_data8.Buchpreis.value}

Good luck🙂
I will be offline for the next three days.
Anja
deltafidesign 22 Sep, 2017
Thanks pixelhexe, I've tryed your solution but with {var:read_data8.Buchpreis.value} I got in output "1". What does it means?
pixelhexe 25 Sep, 2017
1 Likes
You have to replace with your own "Read data name" and "Model name" - the above are only valid for MY form example.

Finally I managed it with only one "DB Read action" - after realising that I can add further models there. See my attachment to see further details of my example.
This topic is locked and no more replies can be posted.