how can I set up a form with dynamic fields according to user input? - joomla

I set up a simple form with Chronoform V4. One of the field need to be kinda dynamic.
for example,
do you know your id, if yes, then input id.
if not, then there are other filelds need to be filled, such as name, birthday, sex etc.
but if you know the id, those fields should be grey out or something etc.
How can I do this in joomla? Many thank

Your best bet? Hop on the forums over at www.chronoengine.com - not only are the developers super friendly, I have seen them custom code stuff for their users more times than not.
They know the stuff best and will definitely be able to help you.
That said, there are ways to add custom code snippets to chronoforms - I recommended using javascript to accomplish your goal. I have done something similar and chronoforms + javascript = wonderful result.
If you've created your form with their wizard, go into your forms and click Wizard Edit.
From there on the right hand side you should see an 'Events' tab - click that.
In the 'On Load' event, you'll want to add 'Load JS' from the menu on the left. Then you can open that, and add your javascript to control your choices. The javascript will load when the form does and you can control the user selections exactly how you're requesting.

Related

Dynamic content display

when I select (say customer) using Dropdown I would want to show users all the properties on a side table or division. Essentially, displaying the selected customer's fields on the same page for the users to verify/read.
I am using laravel-backpack for development and finding it difficult to implement. Any help is greatly appreciated.
I'm afraid there's no existing way to achieve that, you'd have to code it.
But you don't have to start from scratch, you can use the code for the select2 field (or whatever field you prefer) and create a new field type, say select2_and_preview by tweaking the Javascript inside that one file.
There's recently been a Feature Request for a similar feature (see here), you might want to pitch in with your opinion if you want it created by the team, and included in the official build.

Which resources method should handle this view?

I'm currently using Laravel but i assume this question could also be asked with any framework in any language.
If i have a simple form to create an user, with the most basic fields (firstname, lastname, email...), the resource method i'll use will be create to display the view and store to handle the post logic.
After that, the edit form will be displayed in the edit method and the update managed by the update method.
Eventually, the user sheet will use the show method.
Now, imagine i have a view that combine both the edit and show purposes, i mean like a page with multiple tabs, where each tab display information about the user, some charts, some tables, a lot of stuff... but also an edit form in one of these tabs.
Which method should be used to display this view ? edit or show ? Since it acts like a show but also have a form to edit the user... i'm always asking myself and sometimes i have a hard time to figure out which method i should use.
This case often happens in back offices, where some edit pages looks like a dashboard more than a simple form, i'm sure you see what i mean ;)
Is there a convention about this ? Something like "if there is a form it's an edit, even if it mainly show information" ?

Composite Fields In MSCRM 2013

I have a question on the subject of composite attributes that I would be grateful if you could help me with.
I posted this before on other question blogs but got no response I am satisfied with.
I am writing JavaScript that will update the fields (i.e. address1_line1, address1_line2, address1_line3, address1_city, address1_stateorprovince, address1_postalcode, address1_country) in the composite (address1_composite). When the fields are updated the composite does not seem to update. I have to open the composite and close it again. Is there a way of doing this automatically in JavaScript?
I have tried the following ideas:
Idea 1:
Xrm.Page.data.entity.save();
This is recomended at http://community.dynamics.com/crm/b/magnetismsolutionscrmblog/archive/2013/10/22/working-with-dynamics-crm-2013-composite-fields-fly-out-menu.aspx
This is not any good as my customers want to view the composite before saving the page. Also I would not want to save the page for my customers as they do not want this. They would like to decide when to do this themselves.
Idea 2:
Xrm.Page.data.refresh();
This is not really what I wanted as I do not want to refresh the whole page. I just want to refresh the composite. Also it bring up a popup that warns you about not having saved the page which will be annoying for my customers.
Idea 3:
Writing the address from the address lines to the composite.
This feels like a nasty hack.
There is probably more than one way of doing this. I used the function
Xrm.Page.getAttribute("address1_composite")._attribute.setValueForCompositeField();
I do not like this for the following reasons:
This is a hack as it is not using the system functionality of the done button to write the data.
You do not get the system formatting you get with the done button although this will get done when the form is saved so it is not so bad.
In the future if customers are allowed to add their own composite fields it could cause problems as the field names could be different.
It requires me to write extra code for each form that has a composite which has fields with different schema names. E.g. I have to write different code for forms with ShipTo and BillTo addresses as the code for the account form will not work.
Another idea was to set the focus to the composite field after a change has been made to any of the fields inside the composite.
Xrm.Page.data.entity.attributes.get("address1_composite").controls.get(0).setFocus();
This is the best idea so for but it is far from perfect. This forces the user to press the done button and hence the fields will be written. I was hoping for something more automated.
My Question:
What would be great is if there was a way to click the composite done button in JavaScript. This would give me the formatting of the done button and the automation I need.
Update - 14/04/2014
Since posting this question I have been in contact with Microsoft and they say there is no supported way of clicking the done button via a program.
If the field is locked down CRM JavaScript does not send the data back to the server for updating. Another approach would be:
perform the update using JavaScript (so the user sees the change); and
use a server side plugin on the Update event so the value is persisted.

Can I create quiz GUI with Django-Forms?

I'm new to django, and I'm working on a quiz project. The idea is to create something similar to this (http://www.stylemint.com/quiz). Basically, there will be a question on each page and the user clicks on an image with the answer. I was planning on using a django form with a radio select input type, however, I'd like the image to act as the radio button (ie, be clickable) and also a click on the image will take you to the next question (instead of having to click submit after each). Is this possible with django, or do I need java?
it's perfectly possible - if you just want a series of images, and clicking on them to take you to the next question you might achieve that by:
Having multiple input fields of type "image" which all submit the form. If you go down that route you'll have to template the forms out yourself or make your own widget.
Using javascript to replace radio buttons with images dynamically. If you do that, it'd be a good idea to make it fall back to a straight list selection for people who don't have javascript.
Ignoring forms altogether and just using a view with a parameter of what the choice is.
Yes, it's completely possible. My suggestion is if you want to save the result in the db use model and model form in django. So, my next suggestion is you can customize model field for combine radio button functionality and image together. But actually you must programming and use a little jquery and javascript to do it.
You may want to see:
https://docs.djangoproject.com/en/dev/topics/forms/modelforms/
https://docs.djangoproject.com/en/dev/howto/custom-model-fields/

Insert relational data in lookup table

I am managing to construct a form (with FuelCMS) that has a look-up table, and the look-up table has a field that must be inserted at the same time as the relation (Figure 1).
Using a model inside my module I have finished the form to insert the data, I have a control (Figure 2) to select the relation between the two tables, and here is where my question comes. I need to show a pop-up (like the one when you press the "ADD" or "EDIT" button that allow the user to insert the value of the "objetivo" field (Figure 1) at the time you assign "Hitos" to the "indicadores".
What is the best way to do this? Can I attach a JS file to the form from the module to be able to capture the button click and show the pop-up? There are another better way already to achieve that task?
I hope I made my point clear, if not, please tell me and I will try to explain myself better.
Thanks :)
Figure 1
Figure 2
Thanks to the kind of the FuelCMS team I was at the end able to solve the situation I explained before, to achive the aim you should follow the next steps:
Add a javascript file on the module config (fuel/modules/MODULE_NAME/config/MODULE_NAME_fuel_module.php)
Use the Javascript hooks 'selectionAdded' and 'selectionRemoved' to launch the popup (FuelCMS uses jqmodal as popup) the functions pass as a parameter an array "vals" that contains the ID of the selected items.
Add a AJAX request in the popup code to retrive the form
Process the form and keep the values for later saving on database or manipulatiĆ³n.
It could be a bit tricky if you need a complex logic but is an effective way of do it :)
Once again TAHNKS to the FuelCMS support people, i hope this help someone.
Best regards.

Resources