Embeding the Public Submit form into a static html page

avatar Leon P. Dev May 6. 2009. 9:30 am
Hello..

Is it possible to 'plug' aC's public submit form into a custom/static html file that would be on a different domain? Basically I want to make it easy for my client to send feedback on some work I'm doing, and would like to embed the form into the page I'm working on.

I was thinking of just pulling the code from the form (between <form> and </form>) but then realised the action="" attribute is blank...

Sooo.. Any tips on how to go about it?

Thanks, Leon.
avatar Panagiotis K. Dev May 6. 2009. 11:09 am
Hello Leon, first of all, you theme about iPhone (Access Mobile Module) is great i will use it for sure when i will buy the license!

Sencod, a form with blank action post's data to current location. So if you take the form along with its javascript files that required for validation and type into action="" URL that points to your Active Collab system will work :)

PS: I didn't tested it but I think that will work :)
Aviantâ„¢ | Zend PHP 5 Certified Engineer
PHP Development / Symfony 2 / Zend Framework / JavaScript / HTML5 / CSS3
Online CV: panosru.com
avatar Ilija Studen Staff May 6. 2009. 4:56 pm
Hi Leon,

Sorry for the late reply. Although you can submit POST request (it needs to be send to the URL of public submit form) with proper fields and have it processed by activeCollab, we recommend that you use form prepared by the system. Maybe you can use IFRAME?
avatar Leon P. Dev May 7. 2009. 9:57 am
@panosru and @Ilija - Thanks for the replies.

I did think about using the IFRAME option - this would have probably worked best but I wanted the form to be different to the standard layout. I realise I can customise the standard layout however for the styling I want to do it would not be suitable for my other clients.

Is it possible to 'duplicate' the public submit module so I can have 2 versions?
avatar Panagiotis K. Dev May 7. 2009. 10:43 am
I have the same question with Leon.

Also it would be nice if public submit module allow us to produce referent urls for different projects.

Another option would be a setting in public submit module so new submit url automatic created on project creation.
Aviantâ„¢ | Zend PHP 5 Certified Engineer
PHP Development / Symfony 2 / Zend Framework / JavaScript / HTML5 / CSS3
Online CV: panosru.com
avatar Ilija Studen Staff May 7. 2009. 4:53 pm
What you can do is to open form's source code and replicate the form on other page. Field names need to reman the same for system to work (don't forget hidden fields) and you should disable CAPTCHA protection. Form action should be the address of public submit form.

Another option is to create a tool that submits tickets through the API. This way you can have even more control. Please check this article to learn how to work with tickets using activeCollab API.
avatar Leon P. Dev May 8. 2009. 4:13 am
Thanks Ilija,

I've turned off CAPTCHA and I'm able to post a ticket via the form from a static page now (using action="http://mydomain.com/submit" in the <form> tag). But it's not quite how I'd like it still. The user is taken to the 'successfully submitted ticket' page on my ac install after clicking 'submit', but I would like to keep them on the same page (also for handling form validation).

I've done a search and played around with a few solutions but haven't had any success yet. I've gone with one from 9Lessons as it's the cleanest, and I'm feeling it's almost there but for some reason it's just not working:

The head/javascript bit:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.0/jquery.min.js"></script>
<script type="text/javascript">
$(function() {

$(".submit").click(function() {

    var name = $("#created_by_name").val();
	var email = $("#created_by_email").val();
	var subject = $("#name").val();
	var description = $("#body").val();
	var submitted = $("#submitted").val();
	
    var dataString = 'created_by_name='+ name + '&created_by_email=' + email + '&name=' + subject + '&body=' + description + '&submitted=' + submitted;
	

	if(name=='' || email=='' || subject=='' || description=='' || submitted=='')
	{
	$('.success').fadeOut(200).hide();

    $('.error').fadeOut(200).show();
	
	}
	
	else
	{
	$.ajax({
	type: "POST",
    url: "http://myactivecollabinstall.com/submit",
    data: dataString,
    success: function(){
	$('.success').fadeIn(200).show();
    $('.error').fadeOut(200).hide();
		
   }
});

	}
		
    return false;
	});

});
</script>


The HTML/form:
  <form enctype="multipart/form-data" method="post" name="form">
    <div class="info" style="padding-left:20px">
      <h2>Submit to activecollab form</h2>
    </div>
    <ul>
      <li id="foli1">
        <label class="desc" for="created_by_name">Name</label>
        <div>
          <input id="created_by_name" name="ticket[created_by_name]" type="text" class="field text medium" value="" maxlength="255" tabindex="1" 						/>
        </div>
      </li>
      <li id="foli3">
        <label class="desc" for="created_by_email">Email</label>
        <div>
          <input id="created_by_email" 	name="ticket[created_by_email]" type="text"	class="field text medium" value="" maxlength="255" tabindex="3" />
        </div>
      </li>
      <li id="foli4">
        <label class="desc" for="name">Subject</label>
        <div>
          <input id="name" name="ticket[name]" type="text" class="field text medium" value="" maxlength="255" tabindex="4" />
        </div>
      </li>
      <li id="foli6">
        <label class="desc" for="body">Description</label>
        <div>
          <textarea id="body" name="ticket[body]" class="field text medium" tabindex="5"></textarea>
        </div>
      </li>
    </ul>
    <div class="buttons">
      <input type="hidden" name="submitted" value="submitted" style="display: none" />
      <button type="submit" accesskey="s" value="Submit" style="background:#0060a1; color:#FFFFFF; font-size:14px; border:1px solid #0060a1; margin-left:12px" class="submit"><span>Submit</span></button>
      <span class="error" style="display:none"> Error</span>
      <span  class="success" style="display:none">Success! Ticket submitted.</span>
    </div>
  </form>


What am I doing wrong?

*time for a coffee*

Leon.
avatar Ilija Studen Staff May 8. 2009. 4:28 am
What is not good with your approach is that you are hacking the system into working the way it was not designed to work. This usually ends up with problems and it's not as reliable as it should be.

If you wish to fully control the process - form, landing page, validation etc, you should use API instead of hacking public submit page:

http://www.activecollab.com/docs/manuals/developers/api/tickets
avatar Leon P. Dev May 8. 2009. 4:52 am
Thanks Ilija - I've never worked with API's before so please bare with me on this learning cure.

The thing I'm not understanding is how the API could work in a 'public submit' form without using Authentication?

From what I understand, the user must be authenticated (logged in) to submit a ticket via API, however I do not want the user to be logged in at all (there will be many people submitting feedback via the form).
avatar ntm Pro May 8. 2009. 2:20 pm
You could use your form HTML and set the target to be an iframe (possibly hidden)

<iframe name="AC_Target"></iframe.
<form target="AC_Target"></form>

Then using the onSubmit event for <form> you display a success message.

It will have issues if there is a problem since you wont see the real response from AC... but that's the risk you're taking by going in the custom html direction anyways =)
or Go To Next Page

Try activeCollab free for 30 days, No credit card required!

Instant access to activeCollab, no installation needed.

.tryactivecollab.com

If you are already a user of activeCollab, you can log in here.