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?

pre-complete form fileds using form weblink

More
10 years 2 months ago #792 by Ardkorian
Is it possible to pre-fill out certain form fields using the http link to the form page.

we have a price box that we want to complete, and we want to send a link to the user for them to follow so theycan fill out their forms with their individual price already completed.

e.g

website.com/index.php/forms?price=450/

form:

name: <blank>
event: <blank>
price: 450 <----pre filled form based on info in link above

I am new to php and joomla forms, and don't fully understand the syntax required to achieve this if it is possible.

More
10 years 2 months ago #793 by Administrator AV
Replied by Administrator AV on topic pre-complete form fileds using form weblink
Hi,

in order to make forms as save as possible, I decided on not using url parameter in the way you request it. It's not very difficult for anybody to change the price in your example, is it? So no, that is not possible, there would be no right syntax at all.

I would like to understand why you think you need to pass the price parameter through the url? Where would the price value come from in the first place? What exactly do you want to accomplish?

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
10 years 2 months ago #794 by Ardkorian
Replied by Ardkorian on topic pre-complete form fileds using form weblink
Our forms will be hidden, and only people that we direct to the forms using the link would use them.

Majority of our users will not be tech savvy, and wil follow the link we give them.

We will have already agreed a price via email or phone when they first contact us, so rather than doing 100s of different forms with £10 increments, we want 1 form, that we can link to with the price passed from the url.

The form will also do a calculation on the price submitted to tell the user what their deposit and final balance is.

There would be no advantage for the user to amend the price as we would already have a record of the quote.

This form is for user information only. And not as a shopping cart.

Thanks

More
10 years 2 months ago #795 by Administrator AV
Replied by Administrator AV on topic pre-complete form fileds using form weblink
Hi,

thanks for the details information.
Actually that is quite a specific use case and not possible with Visforms out of the box, but I think it's possible to realize.
If I had to extend Visforms for a client with your feature I would not try to interfere with the core code of Visforms (php) but use Javascript, because there would be quite a lot of php code to be changed and you would have to maintain those changes individually with every update of Visforms.

I woud try to place the Javascript inside the index.php of the template and not in Visforms files to prevent it from being overridden by updates of Visforms.

You can add any parameters to the Url that calls the form. The parameters are not cut away our such things. So the Url you send to your clients would look something like

yourJoomlaWebsite/index.php?option=com_visforms&id=1&field1=450

where id is the form's id and field1 is your price field
Please do not link the form to a menu item, because this would cause the SEO router to convert option=com_visforms&id=1 into a SEO url.

The input of every form field (which is represented by an HTML input) has a specific id which is composed from the string "field" and the field's id (which you can find in the id column of the fields view in backend). (So This will not work for radios or selects but I think that is of no concern to you).

Essentially you have to write some Javascript code to get the Url parameter. If you are on Joomla! 3 you could preferrably use jQuery which is already part of the Joomla! core but must of course be included in the template. If you are on Joomla! 2.5 using jQuery may cause problems so you could use just Javascript without a framework like jQuery.

The following Javascript function should do the trick without jQuery but of course I have not tested it on many browsers
Code:
function getArg(name) { var args = new Object(); var query = location.search.substring(1); var pairs = query.split("&"); number_of_arguments = pairs.length; for (var i=0; i<number_of_arguments; i++){ var pos = pairs[i].indexOf('='); if (pos == -1){ continue; } var argname = pairs[i].substring(0,pos); var value = pairs[i].substring(pos+1); args[argname] = unescape(value); } if (args[name]){ return args[name]; } else { return null; } }

You can use some code similar to the following one, to set the parameter value from url as input value
Code:
var field1value = getArg('field1'); var field1 = document.getElementById("field1"); field1.value = field1value;

Of course you have to make sure, that you only run the code when you display the form and that the field is available and so on, but you can use the getArg() function to check if the url contains the option=com_visforms and the id=1

I just outlined the principles of the solution here, not a fully developed and tested solution. I hope you have some coding skills and can transform the sketch into working code following my instructions.

If you have further questions, feel free to ask.

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