Joomla 5 Notice

We are pleased to announce that as of January 29, 2024, all of our Joomla extensions are compatible with Joomla 5.

For all who are still updateing from Joomla 3 to Joomla 4: Joomla 4 Migration instructions are available here:

There is now a separate Documentation for Visforms for Joomla 4 and for Visforms for Joomla 5!

Forum

Visforms Subscription user can ask questions in our forum. Please log in with the relevant user first.
Everybody can access the forum for reading.

Please only ask 1 question per topic.

Important information for almost every question:
V1: Which Visforms version is running?
V2: Which Joomla version is running?
V3: Which PHP version is running?

Get field value in onVisformsBeforeFormSave

More
5 years 9 months ago #6074 by fstadelmann
Get field value in onVisformsBeforeFormSave was created by fstadelmann
Hi

I try to get a field value in onVisformsBeforeFormSave.

I tried with the help of the $fields argument, but without success, I only get a empty string.

Can you please give me a sample how to get a value of a form field in the onVisformsBeforeFormSave function of my custom plugin.

Thank you!
Felix

More
5 years 9 months ago #6075 by Administrator AV
Replied by Administrator AV on topic Get field value in onVisformsBeforeFormSave
Hi,
in order to handle all the business logic which is provided by visforms, there is not just one "value". There is a difference between the value, which is retrieved from the POST (and validated) and which is saved in the database and for example the value which is used as value, when the form is displayed.

If you are interested in the value which is stored in the database you can access them as $field->dbValue.

If you need any further help, just ask.

Kind Regards,
Aicha

:idea: I recommend you the new and up-to-date documentation for Joomla 4:
docs.joomla-5.visforms.vi-solutions.de/en/docs/
Most of this also applies retrospectively to Joomla 3.
Please only ask 1 question per topic :-).

:idea: Ich empfehle Dir die neue und aktuelle Dokumentation für Joomla 4:
docs.joomla-5.visforms.vi-solutions.de/docs/
Das meiste gilt rückwirkend auch für Joomla 3.
Bitte immer nur 1 Frage pro Thema stellen :-).

More
5 years 9 months ago #6076 by fstadelmann
Replied by fstadelmann on topic Get field value in onVisformsBeforeFormSave
Hi Aicha

Thank you very much for your answer!

Assuming the database field is named "test", then I get the database value by $fields->dbValue("test"). Correct?

By the way, is there a listing of all the "properties" of $fields and the other arguments?

Kind regards
Felix

More
5 years 9 months ago #6077 by Administrator AV
Replied by Administrator AV on topic Get field value in onVisformsBeforeFormSave
Hi,

the field has really a lot of properties and there is no list of them. I would really recommend, that you use some sort of IDE when you try to develop custom code. php storm im great for example, but it is not free. But there are free php IDE's, too. Using a IDE gives you the opportunity to set a cursor anywhere in the code and acually see, what is available there....

The event handler function receives a fields objects array. You have to loop through these array (foreach $fields as $field) . If you want to do something with a field that is named "test" then you have to check that $field->name == 'test' and then you can get the dbValue property of that field. $field->dbValue; (this is not a function but a property of the field).

Regards,
Aicha

:idea: I recommend you the new and up-to-date documentation for Joomla 4:
docs.joomla-5.visforms.vi-solutions.de/en/docs/
Most of this also applies retrospectively to Joomla 3.
Please only ask 1 question per topic :-).

:idea: Ich empfehle Dir die neue und aktuelle Dokumentation für Joomla 4:
docs.joomla-5.visforms.vi-solutions.de/docs/
Das meiste gilt rückwirkend auch für Joomla 3.
Bitte immer nur 1 Frage pro Thema stellen :-).

Moderators: Administrator AVAdministrator IV
Powered by Kunena Forum