Want to set up Date Picker

JP

Member
Debbie,

Any ideas on how to make the asterisk (*) for required fields go away once a record has been updated (no longer empty)?

Thanks,



Post Edited (10-28-09 17:22)
 

DebbieS

DaDaBIK Guru
Have you tried to add an if update/extupdate (you know), then no star?

On or about line 598, you'll see the following:

if ($fields_labels_ar[$i]["required_field"] == "1" and $form_type != "search"){
$form .= "*";
} // end if

What if you changed it to show ONLY if it is the insert form is displayed:

if ($fields_labels_ar[$i]["required_field"] == "1" and $form_type == "insert"){
$form .= "*";
} // end if

.....

 

JP

Member
Debbie,

Yes I have been messing with that section on and off all day and can't seem to get it to totally work right. I still want it to show on the update page but to go away after an update has been made. The problem I seem to be having is the asterisk (*) only shows next to one of the required fields when empty but is gone like it should be when both required fields are filled or vice-versa when using the code below.

if ($fields_labels_ar[$i]["required_field"] == "1" and $details_row[$field_name_temp] == ""){

I'm still digging. I am looking at maybe some jQuery validation to replace the required field code built into DaDaBIK.

Thanks for all your help, I sure do appreciate it :)

 

DebbieS

DaDaBIK Guru
Well then I don't know. It is typically one of those things that I would just leave as is -- technically the field is still required so there isn't anything missing in the logic for the person viewing the form.

 

JP

Member
I have not removed / turned off required fields in DaDaBIK, I'll probably leave it alone per Debbie's suggestion but I did add jQuery form validation and it works great. Pictures are below...

Form errors if saved with missing entries.

validation.png


Form errors if incomplete or invalid form entries (Date is incomplete).

validation2.png



----------------------------------------

Debbie I do have one more question I hope you can help with. On the "Received By" select_single do you think it would be possible to add some kind of if statement to change this from a select_single to a readonly text field after it has been updated and saved?

Thanks :)



Post Edited (11-08-09 22:45)
 

DebbieS

DaDaBIK Guru
For the select single readonly thing, you could change the text you previously put in to display only two entries ... assuming the values are not coming from another table using primary keys ...

FROM.....
case "select_single":
$form .= "<td class=\"td_input_form\">".$select_type_select."<select name=\"".$field_name_temp."\">"; // first part of the second coloumn of the form

if ($field_name_temp == "YOUR_FIELD_NAME") {
$form .= "<option value=\"".$var_for_current_user."\">".$var_for_current_user."</option>
<option value=\"ADDRESSEE\">ADDRESSEE</option>";
} else {


TO.....
case "select_single":
$form .= "<td class=\"td_input_form\">";

if (($form_type === 'update' or $form_type === 'ext_update') && ($field_name_temp == "YOUR_FIELD_NAME") && ("YOUR_FIELD_NAME" != "")) {
$form .= "<input type=\"hidden\" name=\"".$field_name_temp."\" value=\"".$details_row[$field_name_temp]."\">".$details_row[$field_name_temp];
} else {

$form .=
$select_type_select."<select name=\"".$field_name_temp."\">"; // first part of the second coloumn of the form


Basically this is moving that field display out of the select single "area" and making it display as a text field ONLY if the form is UPDATE AND the field name matches AND there is something already entered. Otherwise it should behave as a normal select single in the insert/update forms.

I've not tried it, but logically it seems that it should work. The hidden input field saves the existing value on form update.

 

DebbieS

DaDaBIK Guru
JP ... I've a question for you ... what jQuery form validation are you using? Is it easy to implement?

 

JP

Member
Debbie,

Thanks for the input for the readonly. I was messing with this last night and remembered you could not use "readonly" for <select> and <option> form elements but you could use "disabled". I wanted to keep the code you gave me for having the two entries/users as the only choices in the select_single field since I don't want to allow other users to be able to receive something and select a different users name. So I came up with the following:

case "select_single":
if ($field_name_temp == "MY_FIELD_NAME" && $details_row[$field_name_temp] != "") {
$form .= "<td class=\"td_input_form\">".$select_type_select."<select name=\"".$field_name_temp."\" disabled=\"disabled\">";
}
if ($field_name_temp == "MY_FIELD_NAME" && $details_row[$field_name_temp] == "") {
$form .= "<td class=\"td_input_form\">".$select_type_select."<select name=\"".$field_name_temp."\">"; // first part of the second coloumn of the form
$form .= "<option value=\"\">Select...</option>"; // first blank option
$form .= "<option value=\"".$var_for_current_user."\">".$var_for_current_user."</option>
<option value=\"addressee\">addressee</option>";
}else{

This picture shows the two user only mod you shared with me. (before update is saved)

update5.png


This picture shows the "disabled" mod applied to the <select> form element. (after update is saved)

update6.png


Thanks for all of your help Debbie, this update form is exactly the way I need it. Once a shipment has been received NO information can be changed nor can any user except the logged in user receive the shipment.



Post Edited (11-08-09 22:46)
 

JP

Member
Debbie,

I am using the jQuery validation plugin from this site -> http://bassistance.de/jquery-plugins/jquery-plugin-validation/

It requires jQuery 1.2.6 or higher. I am using 1.3.2 that can be downloaded from here -> http://jquery.com/

Default download option for production is all you need.

Add the following in between your <head> </head> tags

<script language="javascript" type="text/javascript" src="../js/jquery-1.3.2.min.js"></script>
<script language="javascript" type="text/javascript" src="../js/jquery.validate.js"></script>

jQuery can be called from class= for each form element but I don't want to hard code all that into business_logic.php so all the jQuery form rules are in a separate js file.

<script language="javascript" type="text/javascript" src="../js/jquery.form.rules.js"></script>

An example of the form rules used for the update form you have helped me with would look something like this inside the jquery.form.rules.js file

$(document).ready(function() {
$("#update").validate({
rules: {
date_received: {
required: true,
date: true
},
received_by: {
required: true
}
},
messages: {
date_received: {
required: "Date received is required",
date: "Please enter a valid date."
},
received_by: {
required: "Received by is required"
}
}

});
})


Note: The date_received and received_by are element names in my form/database and are just an example.

The form does need an id= which DaDaBIK already has in the function build_form section of business_logic.php

Example: $form .= "<form id=\"dadabik_main_form\" name=\"contacts_form\" method=\"post\" action=\"".$action."?table_name=".urlencode($table_name)."&function=".$function;

But since this is used in all forms (insert,update,search etc..) you could run into trouble if you had the same form elements in an "update" form and a "search" form and validation was only needed for the "update" form. So what I did was add IF statements for the different types of form types to change the id= as needed.

Example for form type update:

if ( $form_type == "update" or $form_type == "ext_update") {
$form .= "<form id=\"update\" name=\"contacts_form\" method=\"post\" action=\"".$action."?table_name=".urlencode($table_name)."&function=".$function;

This should get you started. jQuery can do a lot of cool stuff. I even found a jQuery pop calendar I may try out.

Let me know if you have any other questions :)



Post Edited (11-05-09 22:49)
 

DebbieS

DaDaBIK Guru
Thanks JP ... haven't gotten it to work -- been in a time crunch to get a project complete and could not afford the time to see what was hanging it up (could be a conflict with another bit of code that I could not find). For now I'll stick with my fValidate and look at this when I'm not on a deadline (once the project is finished, I can "play" and test things - for now I just have to get it to work).

 

JP

Member
Debbie,

I totally understand the time crunch on projects. I'm sorry you were not able to get it to work just yet. I'll help in anyway I can when you have the time.

One thing I did forget to include was the CSS.

This is in my style sheet.

label.error { float: none; color: red; padding-left: 0.5em; vertical-align: middle; font-size: 0.875em; font-style: italic;}

The element label and class error are the default values in jquery.validate.js and are dynamically created by the script, no need to add anything to your form.

Good luck with your project :)



Post Edited (11-08-09 22:49)
 

JP

Member
Hi Debbie,

Did you ever get a chance to tackle jQuery form validation on one of your installs?

 

DebbieS

DaDaBIK Guru
JP ... nope. Before my last project was complete, I got dumped on with a few new ones ... this has gone to my "filler work" pile for the day when I've got to find something to do ... lol ... OR when the current validation I'm using ceases to work. Right now I'm using fValidate JS validation and it's working without fail so I'm letting sleeping dogs lie as it were.

We are also getting close to server upgrades so I'm not planning any big code changes until after that's finished.

On the home front, I've been busy trying to get my hubby's PC performance to improve with Win7 on a Raid stripe array. PC is painfully slow and I cannot seem to fix that. Driving me nuts!

 

JP

Member
Debbie,

You have a good point. If it isn't broke then don't fix it.

Raid in your home network? You must have some serious data or you just don't want to loose anything. Is this easy to implement and what kind of cost is involved? I'm running Win7 on a brand new box and I am pretty impressed so far.

 

DebbieS

DaDaBIK Guru
JP ... well after much frustration and fighting with a PC that did not want to have any part of what I was trying to force on it ... we discovered the mobo was the culprit, not the raid. W7 just ground to a halt when running W7 so I reverted his machine back to XP until he gets a new mobo. Asus confirmed they do not support his mobo on W7 and have no plans to - and it is only 3 years old! Oh well ...

I suppose it is still prudent to check each piece of hardware to confirm it is supported and not just trust the M$ W7 "is my machine capable" software ... d'oh!

Hubby wanted raid for the speed / performance for his gaming and other stuff he does ... been happy with it so far.

 

JP

Member
I play games with the kids on the PS3 that's about it for me and gaming. Hope all works out with the PC.

 

JP

Member
Hi Debbie,

I'm at it again and need some guidance if you have some time.

Started messing with the update form again. The date received and received by are working just fine. I did have date received as read only and changed it to disabled after a date has been added just like the received by select single is, kinda like the look of it better.

Anyway here is what I'd like to do, I want to disable the submit (Save) button if the date received or the received by has been previously filled in. I can do it with the fields that I am working with but how about the button, is there a way to disable the button after a save?

Here is the record not updated yet.

save1.png


Here is the recorded updated in it's current form.

save2.png


Here is how I would like it to look after it is updated.

save3.png


As you can see the "Save" button is disabled. I did that manually (hard coded) in business_logic.php and I'm sure there is an "if" statement to pull this off but I haven't figured it out yet.

Any help would be greatly appreciated :)

 

DebbieS

DaDaBIK Guru
What if you use the same code to disable the fields in the place where the Save button is and then have it display the save button when the two fields are not completed and display a note "Record is read only" or something when those fields match the criteria for being disabled?

 
Top