PDA

View Full Version : Validating Data Assist Insert Multiple Records


jwright114936
06-01-2009, 09:00 AM
First I am beginning to wonder whether it is possible to validate an Insert Multiple Records. Is it? If it is what is the sequence.

1. I have first created the form.
2. Setup the validation
3. Set the show if validation fails.
4. Bound the form fields to the validated values
5. Applied the repeat selection behavior
6. Applied the Insert Multiple Records Behavior.

This inserts the data, but doesn't validate.

I then tried appending _<?php echo $RepeatSelectionCounter_1; ?> to the validated field name.

<input name="contactLastName_<?php echo $RepeatSelectionCounter_1; ?>" type="text" class="bodyCopy" id="contactLastName_<?php echo $RepeatSelectionCounter_1; ?>" value="<?php echo(ValidatedField("epsReferences","contactLastName_<?php echo $RepeatSelectionCounter_1; ?>")) ?>" size="20" maxlength="25">

I am getting an ! to the left of the insert multiple records behavior as well.

Any suggestions?

Jack

Dave Buchholz
06-02-2009, 12:48 AM
I asked WA Support about this very subject back in August 2008 and their answer was


Validation Toolkit does not support form elements that include a dynamic from elements name, because the Validation tool kit will insert code that validate form elements using the form element name.


I ended up using a JS solution as this was part of a multiple add to cart routine that I was working on which you can see in action here: http://www.murranji.com.au/image-collections/black-and-white/image.php?name=is-it-a-sine&id=46

Ray Borduin
06-02-2009, 05:53 AM
Dave is correct. This is not currently supported.

jwright114936
06-02-2009, 09:58 AM
Any idea when it may be supported? Why did they develop a Multiple Record Insert that can't be validated?

Ray Borduin
06-02-2009, 10:58 AM
We develop our tools separately, so sometimes one might be more advanced than the next.

We depend on bindings for most of our interfaces to work. With repeated elements, bindings strategy doesn't work, so we would need a pretty major overhaul to get it to work properly.

The reality is that the code would work if you were comfortable writing the loops and adding the validations by hand. It is the DW user interfaces that aren't prepared to work with repeated form elements.

I could try to explain the intricacies that make it difficult to pull off, but it should suffice to say it is a lot easier than it sounds.

jwright114936
06-02-2009, 11:19 AM
So... which direction do I go now? Writing the validation loops and validations by hand? I have to get this done, but I am not a programmer. (The path led to a cliff again.) Could you give a few more clues?

Sades
02-21-2010, 06:35 PM
So... which direction do I go now? Writing the validation loops and validations by hand? I have to get this done, but I am not a programmer. (The path led to a cliff again.) Could you give a few more clues?


I ran into the same problem so i looked for a ajax validation to do this and since you dont have much programing skills i tried this one wich is very very easy to use, check the attachment file here, the only bad thing about this validation is that its client side and needs javascript enable to work.


Ok how to use:


Step 1


download the zip file validation1.5.4.1.zip or go to http://tetlaw.id.au/view/javascript/really-easy-field-validation and download the script it also explain there how to use, but ill explain here how i did it with webassist.


Ok


Step 2
Open the page that has the multiple insert form and in the head of the page look for this in code view and copy paste the scripts file before </head> tag



Should look like this:



<script src="scriptaculous/lib/prototype.js" type="text/javascript"></script>
<script src="scriptaculous/src/effects.js" type="text/javascript"></script>
<script type="text/javascript" src="fabtabulous.js"></script>
<script type="text/javascript" src="validation.js"></script>
<style>
input.disabled {
border: 1px solid #F2F2F2;
background-color: #F2F2F2;
}

input.required, textarea.required {
border: 1px solid #00A8E6;
}
input.validation-failed, textarea.validation-failed {
border: 1px solid #FF3300;
color : #FF3300;
}
input.validation-passed, textarea.validation-passed {
border: 1px solid #00CC00;
color : #000;
}

.validation-advice {
margin: 5px 0;
padding: 5px;
background-color: #FF3300;
color : #FFF;
font-weight: bold;
}

.custom-advice {
margin: 5px 0;
padding: 5px;
background-color: #C8AA00;
color : #FFF;
font-weight: bold;
}

fieldset {
padding: 1em;
margin-bottom: 0.5em;
}

label {
font-weight: bold;
}
.form-row {
clear: both;
padding: 0.5em;
}

.field-label {

}

.field-widget {

}
</style>
</head>


be sure where you placed the scripts files example of one
<script type="text/javascript" src="../folder/validation.js"></script>
the best thing you can do if you dont have much programing knowledge is to past all the scripts in the same folder where your multiple insert page is


Step 3


now after that go to each of the forms elements and add this at the end


Class="require" title="any text to require example please fill your name"


a better example would be like i did for this name field


<input type="text" name="Name_<?php echo $RepeatSelectionCounter_1; ?>" id="Name_<?php echo $RepeatSelectionCounter_1; ?>" value="" size="32" class="required" title="Your Name is required"/>



Step 4


now scroll down to the end of the form it should look like </form>


and add this script:


<script type="text/javascript">
var valid1 = new Validation('FORMNAME', {useTitles:true});
</script>


In that script i have FORMNAME just change it to the name your form has, to know how its named scroll up until you find the opening of the form tag something like:


<form action="your_insert_page.php" method="post" enctype="multipart/form-data" name="FORMNAME" id="FORMNAME">


Save your document and press F12 to test it out.


Hope this helps :D

neilo
02-23-2010, 12:41 AM
Hi Sades,

Thank you for posting your solution!

neilo