Dojo Form Submit Woes - forms

So here's the problem. We have some big dojo forms created using Zend_Dojo_Form. The problem is that validation, while working per element, does not work on any of the submit buttons. Due to the inflexibility of the standard layouts, we're compelled to use viewscripts.
I thought I had the whole thing working fine, that was until I needed to make sure that when you went from page to page of the multipage form using the quick links that it submitted the current page (with validation.)
I noticed that when I force-fired the click event on the submit button, no validation was occurring (or rather, there was no preventing the form submission if there were invalid values. Those values just were not submitted.)
So I looked at some tutorials where I found that the form is validated by calling
dijit.byId('form-id').validate();
or the shortcut I was looking for, primarily (originally)
dijit.byId('form-id').submit();
Neither of which are functions, since the byId is returning undefined. What this means is our viewscript - or whatever the whole process is - generating dojo forms with Zend is partly voodoo anyway - does not actually generate the dojo form dijit.
So how does one do this in a viewscript? As in, what sort of php calls or attribs does one attach to the form tag to get it to be interpreted by Dojo to be the basis for a form dijit?
Here is the code from the viewscript:
<form action="<?= $this->escape($this->element->getAction()) ?>"
method="<?= $this->escape($this->element->getMethod()) ?>"
id="case-record-form">

This sounds very similar to a problem I had. If I rendered the form by echoing it, validation worked, but when using a viewscript it would not. I discovered that when using a viewscript, Zend does not add the form to its zendDijits array, so you have to do it manually.
Add something like:
$script = 'zendDijits.push({"id":"MyFormId","params":{"dojoType":"dijit.form.Form"}})';
$this->headScript()->appendScript($script);
at the top of the viewscript.

Related

Is there a way in Angular2 to display all validations once the entire form is traversed?

I am using Angular2 (2.2.1) for building my web app. I am facing a challenge here. I have multiple dynamic forms in my SPA and in all of them, I am keeping my Sumbit button disabled till all the mandatory fields are filled (I cannot change this behavior because of some restrictions).
My errors are displayed once the field is dirty (and of course if there are errors). However I would like to show that the user has missed some field completely once he has reached the end of the form. I thought of keeping the check on the last field of the form, ie. once it's touched, the validations for all the missing fields will be shown. However there is a major flaw in my logic here as it assumes no user will ever miss the last field which may not be the case.
So, is there any way this can be done in Angular2?

CMSMS FormBuilder submit call custom function

I am using CMS Made Simple for my website.
I have some custom PHP code which I would like to call when a users clicks submit on my Form Builder form.
I know my code is now working correctly, but I cannot seem to find where in the FormBuilder code that I can call the function.
I have had a look through the code in the modules directory but I cannot seem to find where I need to put the code.
Preferably I would like to only use this code on certain forms, but if I have to implement for all forms then so be it.
FormBuilder has a field to call UDTs. In the Fast field adder dropdown choose *Call A User Defined Tag With the Form Results" You may have to use Advanced mode
There is also the UDT integration tab.

web submission automation: simulate onclick event on a title element to load form

A resume-service I use requires that for each listed activity on the resume, there is an hours-per-week field and total hours field. However, the total hours field does not update itself automatically no matter how many weeks pass. My goal is to write a script that does this.
The idea behind the script is:
Log in to website -> go to a certain page -> submit a form** on that page updating the total hours
**unfortunately, for the form to open, you need to click an "edit" title element first which causes it to show up. I've taken a look at the html of the webpage but cannot find the form or input tags corresponding to the form I wish to submit, only that the form is generated with what I think is a javascript function call from the element's onclick field.
I believe the relevant html snippet is:
<a title="edit" class="edit" href="#entry-type" onclick="editComponent('10227041','education');">Edit</a>
but just in case there is a much larger code snippet later in this post (check the 2nd pastebin link at the bottom)
THE QUESTION: Is there a specific language/library/way (preferably in python, although I can work with Java) to simulate an onclick event and that would result in a form loading?
I've worked on this problem a bit, starting with python's mechanize library. I wrote two functions,
def login(br,url):...
def navigate(br,baseurl,url):...
which would satisfy the first two parts of my script's plan, but the third is where the trouble starts. When I print all the forms on the page using
for form in br.forms():
print form
I get http://pastebin.com/Gxy2tc1A
The website's html can be found on http://pastebin.com/PySri5cb
Later I tried to work with Selenium (the firefox IDE plugin) and then exporting code into python, where I would edit it to satisfy my specific needs, but that was a no-go either due to some awkward errors.
Have you looked into GreaseMonkey? You should be able to use that to extract the hours per week, do the math and populate the total hours field. You could probably do the entire thing. Anything that can be done on the page in JavaScript could be done within GreaseMonkey.
EDIT: The code for that site is awful. I especially like the inline call to loadResume() that is made BEFORE the element it writes to (#build-wrap).

Spring form field id with dot doesn't work well with jquery

When I build a form I need to use a dots in path variable. When html is generated inputs has dots in ids. There is a problem with third party jquery plugins like validators. They doesn't work well with dots. Is there a way to change all dots into eg. "_".
One solution would be not to use automatic form binding, so instead of using <spring:form/> you might still use plain HTML tag <form> and handle it regular way. It all depends if you want to benefit from Spring's mechanisms like automatic form field binding and error handling. But if you are handling form validation with JavaScript and you plan to do it across the whole project, you might want to make that effort. What I usually do is to handle client side and server side validation with JavaScript (plain and AJAX), so I'm not using <spring:form/> at all.

form decorators in zend framework

I am new to zend framework. I have used zend form and decorators to make form using class and decorators. The form i created was simple register form.
Now my question is "Is it advisable to use zend form for many complex forms as well ?" i have made many complex forms full of jquery with lots of conditions.. so at this moment i feel that it will very much difficult to make such form using decorators.
The power of form is zend filters and zend validartios which saves our hell lot of time...
So can we make forms in our phtml files and still use the power of filters and validators or is dere any other way...???
Well, my opinion would be to try to make the forms using Zend Form. The reason is that time spent on making Zend_Forms, setting up decorators, customizing elements or creating your own elements will be saved once the form is in use. With Zend Form you get very easy and straightforward way of validating your form, filtering contents of your fields, managing error messages, translating it, etc. In addition, once you spent time on e.g. writing your own or customizing existing decorators, form view helpers, form elements, it will be quite easy just to take them and use them in your next ZF project.
So in my opinion, in the long term using Zend_Form will save you time, even if at the beginning it may seem that using Zend_Form causes more troubles and headaches than not using them.
But off course, if you want to make your forms directly in phtml there is nothing that stops you. Both Zend filters and validators can be used on their own, independently of Zend_Form. You could also create zend form that has the same elements and structure as your "phtml form". This way you could only populate the zend_form, and use it only for validation and filtering of submmited data, not for actual rendering of your form.