The following warnings occurred: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Warning [2] Undefined array key "avatartype" - Line: 783 - File: global.php PHP 8.1.31 (Linux)
|
Unique fields - Printable Version +- Form Tools (https://forums.formtools.org) +-- Forum: Form Tools (https://forums.formtools.org/forumdisplay.php?fid=1) +--- Forum: General Discussion (https://forums.formtools.org/forumdisplay.php?fid=5) +--- Thread: Unique fields (/showthread.php?tid=1321) |
Unique fields - floppyraid - May 22nd, 2011 Greetings, I am really digging this, thank you all who were involved in creating it. I have a (hopefully) quick question. I'm trying to set up an extremely basic inventory tracking log of sorts. I have some fields (columns in tables) that need to have a check for uniqueness. Is this best done in PHP or in an SQL DISTINCT query or by manually forcing a column to have all unique identifiers? I would like to have an indication (not a generic mysql error) that the entry is not unique and is a duplicate for the end user on their browser when attempting to enter it in through a field. So far everything is working great in terms of the forms posting their data into the SQL table, but I do not see anything in the options of Form Tools to have a check for unique data. Again, mad props to all involved in the development of this. I was trying to recreate this very thing by hand for the last 2 days before I discovered Form Tools quite by mistake. RE: Unique fields - Ben - May 22nd, 2011 Hi Floppyraid, Thanks for the kind words! Regarding your problem, there's nothing within the Form Tools Core that let's you check for uniqueness, but its been a common request so I added it to the API. Check out this page: http://docs.formtools.org/api/?page=ft_api_check_submission_is_unique The only drawback is that you have to use the API (i.e. PHP) to submit the code to the Form Tools script, instead of just POST-ing it to it. Here's a couple of tutorials on how to do it, depending on your situation: http://docs.formtools.org/tutorials/api_single_page_form/ http://docs.formtools.org/tutorials/api_multi_page_form/ Good luck! - Ben RE: Unique fields - floppyraid - May 22nd, 2011 Greetings again, I cannot seem to get this thing going. I am hoping that I am overlooking something extremely simple. This is what I have as of right now. Code: <?php As it is now, the data is always added to the table regardless of wither or not the information provided destined for col_2 is unique (col_2 is what the column is named for the unit id's) Sorry, I've tried several ways and read and reread. I am a bit confused by what is mentioned on the page: http://docs.formtools.org/api/?page=ft_api_check_submission_is_unique at the top it says Code: ft_api_check_submission_is_unique($form_id, $criteria, $submission_id]); Code: if (!ft_api_check_submission_is_unique(10, $criteria, $fields["form_tools_submission_id"])) perhaps i am overlooking something very basic (i am by no means proficient in php) if anyone wants to sorta nudge me in the right direction i would be extremely greatful ----- EDIT: sorry, figured it out. http://docs.formtools.org/tutorials/checking_for_uniqueness/?page=uniqueness_check the bottom of the page explains in a little more detail what i needed to know to figure out how i was in error. i didnt see it linked anywhere on the site but a google search of ft_api_check_submission_is_unique picked it up RE: Unique fields - Ben - May 27th, 2011 Ah, good to hear! Sorry the page wasn't too clear. - Ben |