(SOLVED) Button to link to and pre-populate Form

Status
Not open for further replies.

mbeley

Member
For each Candidate in my system there are 3 separate forms: Registration, Training and Employment.
Users have to fill in the Registration form first.
I would like to make a button (from the Candidate Form or Detail view) that would link to one of the other Forms (Training or Employment) and pre-populate the Candidate field.

Just like in Fabrik, in the Groups view, there is an Elements column with an Add button, and it links to an Element Form with the Group field pre-populated.

I had a look at the following documentation:
http://fabrikar.com/forums/index.php?wiki/set-element-defaults-from-url/
http://fabrikar.com/forums/index.php?wiki/button-element/
http://fabrikar.com/forums/index.php?threads/how-does-the-button-work.31450/

I created a Button element in my Candidates Registration Form (formid=1) to link to the Training Form (formid=20).

The JS script is as follows:
var url1 ="index.php?option=com_fabrik&view=form&formid=20&formacao___candidato=";
var url2 =Fabrik.getBlock('form_1').formElements.get('candidatos___id').getValue();
var url =url1.concat(url2);
window.location.replace(url);

It does create a button in the Form and the Detail views, but not in the List view (where I would need it to be).
In the Detail view the button does not work (it is displayed but clicking doesn't do anything)
In the Form view the button works but the link (see below) is missing the url2 part. I am quite sure I made a mistake in the getBlock('form_1') since I did not understand what ('form_123') was refering to in the documentation.
http://www.boagente.com/wconsult/IN...rik&view=form&formid=20&formacao___candidato=

Thanks,
Mathieu
 
I would add a display element (or use an existing element) with a custom link
i.e. list view settings: show in list=yes, link to details = yes, custom link
index.php?option=com_fabrik&view=form&formid=20&formacao___candidato={candidatos___id_raw}

If it should be displayed as a button in list view you can add a static icon or an image in display element's default.
 
Thanks a lot for your help!

I now have an "Add" link in the list view.
The link looks right:
http://www.w-consultoria-informatic...tas/candidatos/form/20?formacao___candidato=2
2 is the id of the record I'm clicking from

But it does not pre-populate the field.
The formacao___candidato field is a database join to the same field (candidatos___id).
It has a concat label (first name + last name) (so that the user does not have to choose from candidate ids) but its value is the id.

Also the word "Add" without a link appears in the candidate form and I do not see a "Hidden" button. Is there another way to hide it in form view?
 
Try with formacao___candidato_raw={candidatos___id_raw}.

Hide: I think you can use element access settings to hide in form/details.
Or use a "field" element (the advantage of the display element: it doesn't store anything in the DB).
 
Adding "raw" worked like a charm.
Hiding in form and details through element access settings did not work (I turned all the buttons to "No" except "Show in List"). So I used a Field element as you suggested, does the job!
Thanks a lot for your help!
 
Are you sure you used the ACL settings, under the "Access" tab? We know those work, so you may either have set them incorrectly, or not used the right settings.

-- hugh
 
Sorry, you're right, I was not using the Access settings, I was talking about the List View Settings.
I guess I would have to use "Special" under Access settings to hide the element in form and detail views.
Right now I don't have an issue using a field element rather than display, so I'll keep it this way.
Thanks!
Mathieu
 
Status
Not open for further replies.
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top