2

I am creating a Wordpress website where I would like to display a specific form on an admin page which has the ability to store form submissions. I have chosen Ninja forms, but I am open to other suggestions.

I am rendering the form using echo do_shortcode( '[ninja_form id=2]' ); However, the form is not displaying on the admin page. I can see there is some markup in the source, but the form is not displayed. I have tried adding all the normal Javascripts to the admin page but with no luck.

The output which is shown in source is:

    <noscript class="ninja-forms-noscript-message">
    Notice: JavaScript is required for this content.</noscript>

    <div id="nf-form-2-cont" class="nf-form-cont" aria-live="polite" aria-labelledby="nf-form-title-2" aria-describedby="nf-form-errors-2" role="form">

    <div class="nf-loading-spinner"></div>

</div>

    <script>var formDisplay=1;var nfForms=nfForms||[];var form=[];form.id='2';form.settings={"objectType":"Form Setting","editActive":true,"title":"Commission Request","show_title":1,"allow_public_link":0,"embed_form":"","clear_complete":1,"hide_complete":1,"default_label_pos":"above","wrapper_class":"","element_class":"","key":"","add_submit":1,"changeEmailErrorMsg":"Please enter a valid email address!","changeDateErrorMsg":"Please enter a valid date!","confirmFieldErrorMsg":"These fields must match!","fieldNumberNumMinError":"Number Min Error","fieldNumberNumMaxError":"Number Max Error","fieldNumberIncrementBy":"Please increment by ","formErrorsCorrectErrors":"Please correct errors before submitting this form.","validateRequiredField":"This is a required field.","honeypotHoneypotError":"Honeypot Error","fieldsMarkedRequired":"Fields marked with an <span class=\"ninja-forms-req-symbol\">*<\/span> are required","currency":"","unique_field_error":"A form with this value has already been submitted.","logged_in":false,"not_logged_in_msg":"","sub_limit_msg":"The form has reached its submission limit.","calculations":[],"formContentData":["commission_amount_1589829372049","submit_1589829400950"],"drawerDisabled":false,"ninjaForms":"Ninja Forms","fieldTextareaRTEInsertLink":"Insert Link","fieldTextareaRTEInsertMedia":"Insert Media","fieldTextareaRTESelectAFile":"Select a file","formHoneypot":"If you are a human seeing this field, please leave it empty.","fileUploadOldCodeFileUploadInProgress":"File Upload in Progress.","fileUploadOldCodeFileUpload":"FILE UPLOAD","currencySymbol":"&pound;","thousands_sep":",","decimal_point":".","siteLocale":"en_GB","dateFormat":"m\/d\/Y","startOfWeek":"1","of":"of","previousMonth":"Previous Month","nextMonth":"Next Month","months":["January","February","March","April","May","June","July","August","September","October","November","December"],"monthsShort":["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],"weekdays":["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],"weekdaysShort":["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],"weekdaysMin":["Su","Mo","Tu","We","Th","Fr","Sa"],"currency_symbol":"","beforeForm":"","beforeFields":"","afterFields":"","afterForm":""};form.fields=[{"objectType":"Field","objectDomain":"fields","editActive":false,"order":999,"label":"Commission Amount","type":"textbox","key":"commission_amount_1589829372049","label_pos":"above","required":1,"default":"","placeholder":"","container_class":"","element_class":"","input_limit":"","input_limit_type":"characters","input_limit_msg":"Character(s) left","manual_key":false,"admin_label":"","help_text":"","mask":"","custom_mask":"","custom_name_attribute":"","personally_identifiable":"","value":"","drawerDisabled":false,"id":5,"beforeField":"","afterField":"","parentType":"textbox","element_templates":["textbox","input"],"old_classname":"","wrap_template":"wrap"},{"objectType":"Field","objectDomain":"fields","editActive":false,"order":9999,"type":"submit","label":"Submit","processing_label":"Processing","container_class":"","element_class":"","key":"submit_1589829400950","id":6,"beforeField":"","afterField":"","value":"","label_pos":"above","parentType":"textbox","element_templates":["submit","button","input"],"old_classname":"","wrap_template":"wrap-no-label"}];nfForms.push(form);</script>

How do I display a form on the admin pages which has submission storage?

How would I enqueue the correct form scripts into the admin scripts?

1
  • 2
    The reason your form not displayed is that Ninja Forms plugin enqueues its scripts and styles using wp_equeue_script() function, and wp_enqueue_scripts action doesn't fire on admin pages. Scripts for admin pages should be enqueued using admin_enqueue_scripts() function instead. I don't know is there a workaround for that or not, but if you clarify your question like "how to include scripts enqueued with wp_equeue_script() function on admin pages", maybe somebody could tell you something about it, or is it possible at all. Jul 7, 2020 at 14:53

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.