In Expressionengine 2.0+, stand alone entry forms (saef) are practically deprecated because of the introduction of the new safecracker entry forms. While the new safecreacker forms are much better as a whole…there is still a need to use them in a stand alone form. For instance, in the backend of EE, there is really no way to create your own custom field for a form. What if I want a select box that only lists the members who have glasses? Obviously, this isn’t a real world example, but there’s still no real way to do that in EE. So we must resort to stand alone forms that we create for the frontend of the site.
If you’ve ever tried to use a saef, you’d know that the javascript portions of the form break outside of the backend. So to remedy this ridiculous problem, I’ve written some custom jQuery to do the trick. In order to use this, you will have to include the jquery script in the header like so:
<code>{exp:jquery:script_tag}</code>
<script type="text/javascript"> // <![CDATA[ $(document).ready( function() { //URL Title js $("input#title").keyup( function() { var titleText = $("input#title").val().replace(/ /g,"_").toLowerCase(); $("input#url_title").val(titleText); }); //Safecracker File js $(".safecracker_file_undo_button").css("display", "none"); $(".safecracker_file_remove_button").click( function() { $(".safecracker_file_input input").removeAttr("disabled"); $(".safecracker_file_thumb").hide(); $(".safecracker_file_undo_button").show(); $(".safecracker_file_remove_button").hide(); var value = $(".safecracker_file_hidden input").val(); $(".safecracker_file_placeholder_input input").val(value); $(".safecracker_file_hidden input").val("NULL"); return false; }); $(".safecracker_file_undo_button").click( function() { $(".safecracker_file_input input").attr("disabled","disabled"); $(".safecracker_file_thumb").show(); $(".safecracker_file_undo_button").hide(); $(".safecracker_file_remove_button").show(); var value2 = $(".safecracker_file_placeholder_input input").val(); $(".safecracker_file_hidden input").val(value2); $(".safecracker_file_placeholder_input input").val("NULL"); ;return false; }); }); // ]]> </script>
I’ve also included the jQuery code necessary to update the url_title field dynamically when the user inputs data into the title field. Be sure to include the url_title field in your form though.