Commit d0ce28f1 authored by Ted Trask's avatar Ted Trask

Add js to HTML views to disable other fields when null or default is checked

parent 77544fd4
......@@ -2,6 +2,28 @@
<% htmlviewfunctions = require("htmlviewfunctions") %>
<% html = require("acf.html") %>
<script type="text/javascript">
if (typeof jQuery == 'undefined') {
document.write('<script type="text/javascript" src="<%= html.html_escape(page_info.wwwprefix) %>/js/jquery-latest.js"><\/script>');
}
</script>
<script type="text/javascript">
function checkboxChanged(){
if ($(this).is(':checked')) {
$(this).siblings(":input").prop('disabled', true);
} else {
$(this).siblings(":input").prop('disabled', false);
}
}
$(document).ready(function() {
$(".nulls:checked").each(checkboxChanged);
$(".defaults:checked").each(checkboxChanged);
$(".nulls").change(checkboxChanged);
$(".defaults").change(checkboxChanged);
});
</script>
<%
local header_level = htmlviewfunctions.displaysectionstart(form, page_info)
local header_level2 = htmlviewfunctions.incrementheader(header_level)
......@@ -37,10 +59,12 @@ for x,name in ipairs(order) do
htmlviewfunctions.displayformitem(myitem, name, -1, "fields")
if not myitem.readonly and form.value.defaults and form.value.defaults.value[name] then
form.value.defaults.value[name].descr = "Default"
form.value.defaults.value[name].class = "defaults"
htmlviewfunctions.displayformitem(form.value.defaults.value[name], name, -1, "defaults")
end
if not myitem.readonly and form.value.nulls and form.value.nulls.value[name] then
form.value.nulls.value[name].descr = "Null"
form.value.nulls.value[name].class = "nulls"
htmlviewfunctions.displayformitem(form.value.nulls.value[name], name, -1, "nulls")
end
htmlviewfunctions.displayitemend(myitem, nil, header_level2)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment