Re-direct button on DetailView

bespokeappstt

Hubstaff freelancer
I have a list here:
Code:
https://www.caribbeanskills.com/index.php/vacancies
And when you click the magnifying glass icon you get the details view
Code:
https://www.caribbeanskills.com/index.php/vacancies/details/12/4
Can I insert a button on the details view that will re-direct to another form and in this new form the value in the list for email will carry across to the new form and when submitted the contents of the new form will send an email to the email address that was carried over from the list.

In effect I want to install an 'Apply Now' button. Hoping I can place it in the same area as the 'Go Back' button. Naturally the new form will give the opportunity to upload a file and several fields to give extra data.
 
You could probably use a calc element to create a link, like ...

Code:
return '<a href="index.php?option=com_fabrik&view=form&formid=123&rowid=&otherform___email={thisform___email}">go to other form</a>';

Obviously change the formid to the new form.

The 'otherform___email' would be the full element name of the email element on the other form. And (surprise surprise) 'thisform___email' would be the full element name of the email element on "this" form (the one you are display and linking from).

You could probably use the same technique to build a button with some onClick Javascript to do the jump to the new form, but get the simple link working first.

-- hugh
 
Is it possible to carry over to the new form a couple of element values from the original form. So when you click the button or link, not only do you go to the new form but you can carry over several values and automatically assign them to elements in the new form?
 
Okay I am using a button and this javascript for the 'click' event works;
Code:
window.location = "https://www.caribbeanskills.com/index.php?option=com_fabrik&view=form&formid=32
This works fine, however the moment I try to bring over the element value in the original form to the new form element value to the second form nothing happens. I just get re-directed to the home page. The name of the element whose value I want in the form with the 'Apply Now' button is
Code:
academic_courses___programme_course
The new form whose element is a read only value and I want to assign the 'programme_course' value to it is:
Code:
programme_course_application___applying_for_course
So the full url that does not work is
Code:
window.location = "https://www.caribbeanskills.com/index.php?option=com_fabrik&view=form&formid=32&programme_course_application___applying_for_course={academic_courses___programme_course}"
Where did I go wrong? Even if I change it to a normal 'field' element in the new form it does not work. Why?
 
Last edited:
Okay, it's something with the braces cause the following url when pasted into the address bar works fine
Code:
https://www.caribbeanskills.com/index.php?option=com_fabrik&view=form&formid=32&programme_course_application___applying_for_course=ElectronicStuff
The new form comes up and the value 'ElectronicStuff' appears in the field element 'applying_for_course'
 
The
Code:
{academic_courses___programme_course}
is not translating into a value. So what should I do to get a value?
 
Last edited:
Any ideas?

It's the weekend. I don't tend to have ideas over the weekend. :)

Anyway, sorry I obviously didn't read your response properly.

I had said to use a calc element, using placeholders. You didn't, you used a button element with some JavaScript. You can't use placeholders in JavaScript. If you want to get the value of an element in JavaScript, you have to do it like this ...

Code:
var program_course = Fabrik.getBlock('form_29').formElements.get('academic_courses___programme_course').getValue();
window.location = "https://www.caribbeanskills.com/index.php?option=com_fabrik&view=form&formid=32&programme_course_application___applying_for_course=" + program_course;

I don't seem to be able to login on the front end (I don't see a login link anywhere), so I can't test this, because the program_course element is only visible for registered.

-- hugh
 
Okay, I'll wait till monday. The login link is in the footer and the text is 'Staff Login'. I tried the javascript but when I click the button nothing happens. I was thinking about using
Code:
document.getElementById('academic_courses___apply_for_programme_course_ro').value
But not sure how you refer to the form. The button name is

apply_for_programme_course
 
Last edited:
Fixed. Two issues ... it was the wrong form ID (it's 28, not 29), and because this is a details view, not a form view, the block name is details_28, not form_28.

Code:
var program_course = Fabrik.getBlock("details_28").formElements.get("academic_courses___programme_course").getValue();
window.location = "https://www.caribbeanskills.com/index.php?option=com_fabrik&view=form&formid=32&programme_course_application___applying_for_course=" + encodeURIComponent(program_course);

As you are using an arbitrary string as the query string arg, I also added the encodeURIComponent() call, to encode any non-URL safe characters.

-- hugh
 
One last question. I want the button value but I don't want the label value. I am thinking to use a javascript 'load' event and use the equivalent of:
Code:
document.getElementById("myBtn").value = "Apply For Programme/Course";
What's the Fabrik equivalent and where can I get documentation on Fabrik's version of Javascript.
 
Are you just trying to hide the label on the left? You could do that with custom CSS (see wiki for how to create a custom CSS file), something like ...

Code:
.fb_el_academic_courses___apply_for_programme_course_ro .fabrikLabel {
   display: none;
}

-- hugh
 
Everything worked just fine. Thanks. Trying to control the margin, ideally would like the button to move to the right where it was originally when the label was showing but I am most fine with what I got.
 
Last edited:
Yeah, no worries. I'm a happy camper. Passing the key value pairs were the most critical part and that was well done I must say.
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top