I am developing a Drupal form which includes a Date field.
I have a number of AJAX callbacks on this form that work well, but now I want to change some form elements depending on the age of the user, so when the date changes, other fields get replaced. Unfortunately, the "#ajax" element is not available on date fields (presumably because the field has three selects, rather than a single select).
Is there another way I can implement an AJAX callback?
I'm considering splitting the date field into 3 selects, which could each have an AJAX element, but that would lose all the benefits of the date field, so I don't want to unless I have to.
Thanks for your help,
James
Related
I'm trying to create a bot to submit a ASP.net form using cURL and PHP. I'm able to do this with simple forms but I got stuck with one email form that uses a grid. Looking the network traffic when submitting the form I found this as one of the parameters posted to the form:
panForm$cbpEmail$FormLayout$grdFaleConoscoDestinatarios: {"selection":"T","callbackState":"z952aVWEs2XJ9DNtuoB8EI0qtZom3Guwv37Ny34ch6u8rMA6ASD0MLgS8vw+0Bz88+PlMhyGnAlnYDZXOy6C0OCBknNqTSUClocyeoOOYcO6KfoLUvLMZWRTBGRY+WUBG3MKabwqmYopS8A42gKWxUHlS7fr98CEILuzK6NAfyuUbgSD878Xtus2kFakVyx9PCQZTvqmUxRS2yiriUhy2C5SkeEjl7htRbAXdgcHr/PM+TRP3QacVdGk52pEBS0IdkY95M7tI8iW55GuMkvhq3exptJZDfibhBx7dvNuZXKX3ro7tVT2FxZVlgrjqwUBi0mGgbMXHbscXTRRJ71LKXf3GSstqEGffjAoZPyJh8LufZ1I4rvSFTuL/CX4ktLel3JYHAolcf4GGgYGbJcou2g9IWIgRJ5OSfQLJyyah8hu1m+zx5QHl6GfDtrbEJVG42agGae97pDLzIAucmEMcySA03aQb1BAE0hUU4qqfXMRlBBnw6WspsGHXsv54xCI2RXP0OlX8cNmfZ0tAgIFO6RLlxRSEhm3ogvaCTVCEgMbfT6bxgrFaF6pLg10GqF9FLCI2r05u/0SzLNTzczXUe444FE4gGf+MZaPgD62AQaxVXt/5QlEKl8kXgKEbNZ8ew8eFT+ldOOy7tiS4aIwmrawrpVisCkJS0FupIGqrFYQ8iRz4GvVgD9eH/lXG0s2aeGLTwcK8MEZ3qp5xKgyY60l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ZITbQ8L2Qtr1jm1ZDYPd2p92yHZgwaNmmtieSsOaxeDNE/l4cVs3kRo5BOXG1V7snk/IOoecMdQ3gJ7UhOMfnD0u4QBRXSrje72ET7jb+RTI=","groupLevelState":{},"keys":["201259","201260","201261","201262","201263","201264","201265","201266","201267","201268","201269","201270","201271","201272","201273","201274","201275","201276"]}
This data represents a grid that is part of the email form where user is able to select who will receive the email.
My question is how can I mimic what ASP.net do to create this data from the grid that is on the page to be able to submit the email form? Does anyone have information about this "callbackstate"?
After submitting a lot of times the same form I realized that I don't need to care about the callbackState. What is important in my case is properly set the selection attribute of this JSON (provided during the creation of the component on the page).
The selection attribute represents the state of the checkboxes in the grid. T means true and F false. selection="T" means only first row selected while selection="FTFT" represents 2nd and 4th rows selected. Remaining rows not represented in the selection attribute are false by default.
Best Regards
Good afternoon. There is a business process with many tasks. In one of the tasks there are two association fields (for simplicity, let's call their field 1 and field 2). As when opening this task, check the value in field 1 and, depending on its value, hide or show field 2?
You can copy the OOTB free marker (.ftl) file for your control. e.g. selectone.ftl located at
alfresco-home\tomcat\webapps\share\WEB-INF\classes\alfresco\site-webscripts\org\alfresco\components\form\controls
then add JavaScript code to it to show/hide your fields.
How can I default to populating the Select drop down list with a value, in this case it would be the country U.S.. We've removed other countries from the list but users are still required to select the one option.
In addition to a default value, the dependent fields would need to be populated. Currently in Intershop, selecting the country populates the State field. I would like to default to U.S. and have the State field already populated on the initial request, sans ajax calls.
You would have to modify some pipelines for this.
The webform it loads is based in the country code. Intershop gets the countrycode from the addressbo or as a parameter. See the ViewUserAccount-ChangeAddress : this pipeline is used in the ajax request to load the webform when u select a country. You could use the same logic to load the U.S webform (US) when the address has not been filled in yet.
I have a workflow to manage employee petitions, that starts with some fields at starter form. The next task, allows a responsable user to approve or reject the initiator user's petition.
I want to show the values of starting form into the approve/reject form, so I created a custom .ftl file for every field that I want print the label and the value. Now I have hard-coded the values to the this:
My problem here, is how to get the value from the first form and print it at the second form (values that I need are where says "200€" and my name).
I'm using Alfresco Community 5.1 and his own Activiti.
Thanks.
Solution 1 : keep IDs of the fields identical in both the forms. this will make the field editable in the second form.
Solution 2 : create a process variable, set its value after the first form has been submitted. then, in the second form display the value of the process variable.
I am working on a form which displays information about orders. Each order has a unique id, but they are not necessarily sequential on the form. Also, the number of fields can vary (one field per row on the form). The input into the form will not be mapped straight into the database, but will be added to the current value in the database, and then saved. An example of the form is in the picture below - the callout on the right shows the id for each row.
I know how to generate the form like this, but I can't work out how I can easily process each of these rows reliably. I also know how to give each of the fields a unique identifier, like name="order-23" or name="order[23]", but how can I translate that name so that I can update the related record in the database?
EDIT: One solution I can think of would be to iterate through every form field in the FormCollection, and if the name of the field matches the pattern, then I will extract the number from that field-name and process it.
However, I feel that there must be a much easier way to go about it - this method would likely involve a fair bit of string processing on each field, and there would possibly fall over if I have to add extra fields for each row later on.
Don't you have a list of IDs after postback? I believe you should not depend on what IDs are actually sent from the form, as anybody could change the IDs on the form to whatever they want, so it's a security issue. So you should after postback have a list of IDs you want to update (the same list you used to create the form with). In that case, you know exactly what id string you should use to retrieve the value from FormCollection.
In case you really can't get the list of IDs you are going to update, just use the FormCollection iteration as you suggested in your comment. The string processing is not that expensive in comparation with all other stuff being done at request processing.
If you have the names, then simply read the values by using Request.Form["order-23"] or re-create the controls in page pre-init and you'll have access to the values in your save event directly through the created controls.
I've done this loads in my CMS.
Essentially i sort of cheated.
The idea is something like this ....
render the form to the client, then look at the source code gneerated.
You should see that it generated a form tag with an action attribute.
When you click the submit button the form will be sent to that url so in the case of an order submission you would post the page back to OrderPage.aspx?OrderId=xxxx
then on the server you would build an update statement for your db that contained something like ...
"Update orders where order id =" + request.querystring["OrderId"]
So how do you update the action ...
In the calling page lets say you have a link called "New Order", when that link is clicked you need to do 2 things ...
redirect to this page.
generate an order id for this new order.
ok the first is simple, simply link it to this page.
the second ...
if this page is not a postback if(!IsPostback) { /* get a new id */ } depending on your order id's this may involve generating a new guid or doing something like getting the next number in a list by doing a select max(id) from a db.
once you have this new id you should still be in the page_load event.
this.form.Action = this.form.Action + "?OrderId=" + yourNewOrderId;
... tada ...
Send page back to the client.
view the source.