Login   Register  
PHP Classes
elePHPant
Icontem

test_auto_complete.php using dynamic option

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us

      Forms generation and validation  >  All threads  >  test_auto_complete.php using dynamic option  >  (Un) Subscribe thread alerts  
Subject:test_auto_complete.php using dynamic option
Summary:Integration with code igniter
Messages:6
Author:clive Turner
Date:2013-03-04 10:51:46
Update:2013-04-16 21:12:55
 

  1. test_auto_complete.php using dynamic option   Reply   Report abuse  
Picture of clive Turner
clive Turner
2013-03-04 10:51:47
Hello Manuel,

I have writing some classes to integrate formsgeneration into the codeigniter MVC framework.


I have very little knowledge of java and ajax, so I am hoping by integrating Code Igniter with forms generation, I can have some easy to use forms without having to write any client side code. I am fairly familiar with formsgeneration as I have used it for a few years.

I'm having difficultly getting the autocomplete forms working when using the dynamic option.


When I put the contents of the "test_auto_complete.php" file (the one that shows colors and fonts) into code igniter controller and load it, it works fine if the options array is loaded client side, but does not show the options if the dynamic flag is set to 1.

Clearly there is some kind of communication problem between the server and client side during the ajax communication, but don't really know where to start looking.

Can you give me an idea of where the problem might be, or suggest some tests I might perform?

I have basic add /edit formgeneration forms working with codeigniter, so there is no issue with post/ get variables getting through. Im thinking there may be a path problem, as I have my code igniter application folder above the public webserver folder for security reasons.

Any insights you may be able to give would be gratefully received.


  2. Re: test_auto_complete.php using dynamic option   Reply   Report abuse  
Picture of Manuel Lemos
Manuel Lemos
2013-03-04 11:03:10 - In reply to message 1 from clive Turner
As you may see in the example code there is a HandleEvent call to the forms class. That is what deals with AJAX requests to fetch any dynamically provided values. You need to somehow make your code call that function.

If the $processed variable is set to true by the class, you need to exit your script without any other output to not corrupt the AJAX responses.

  3. Re: test_auto_complete.php using dynamic option   Reply   Report abuse  
Picture of clive Turner
clive Turner
2013-03-04 13:45:45 - In reply to message 2 from Manuel Lemos
Thanks for your swift response.

I think I have found the source of the problem.

It appears that codeigniter destroys the GET array.

Looking at the HandleEvent method, it appears that the GET array is required for AJAX in formsgeneration to work. Can you confirm?

So I have three options

i) Tinker with the core of codeigniter.

ii) Write a new HandleEvent Method

iii) Settle for loading the options array in one go and not use dynamic loading. Most of my forms have less than 100 options, so probably ok for those (do you agree?). But have a 'town' form with 1000s. Can you give me a steer on how tricky it would be to rewrite the AJAX code so it wouldnt need the GET var. Im thinking pretty tricky?.. and my settle for using linked select for reducing town (options).

Many thanks

Clive Turner.






  4. Re: test_auto_complete.php using dynamic option   Reply   Report abuse  
Picture of Manuel Lemos
Manuel Lemos
2013-03-04 22:41:26 - In reply to message 3 from clive Turner
Yes, AJAX requests have some GET parameters to let the forms class figure what form element should handle the request.

I have no idea why any framework needs to destroy parameter values.

It seems they assume they can control the whole PHP environment. That makes it hard to integrate with anything that they do not control.

It will probably also not work future PHP versions on which parameter values will be made read-only for security reasons.

Why do you need that framework anyway?

I do not think it will be viable for you to rewrite the HandleEvent function. Maybe it is more viable if you save the GET and POST values and restore them before you call the forms class.

The dynamic mode exists precisely to avoid too much traffic and delays when you have a set with too many elements.

  5. Re: test_auto_complete.php using dynamic option   Reply   Report abuse  
Picture of clive Turner
clive Turner
2013-03-06 14:43:08 - In reply to message 4 from Manuel Lemos
Thanks Manuel,

You have saved me alot of time.

I'm using code igniter (CI) to reduce the amount of spagetti code I have a bad habit of writing! The framework is pretty good for ensuring I compartmentalise my models, view and controllers. It has a lot of tools I can use and access quickly. I use smarty too. Joining them all up is always the challenge!

I have decided to continue using your formsgeneration library rather than the one supplied with CI as it as more functionality (especially client side).

I think for the moment I will go down the route modifying CI so it doesnt destroy the GET array.

Thanks again,

Clive


  6. Re: test_auto_complete.php using dynamic option   Reply   Report abuse  
Picture of sonia
sonia
2013-04-16 21:12:55 - In reply to message 1 from clive Turner
Hello,
my name is sonia,i am a young beautiful girl with a lovely heart . i saw your profile today and like to be your friend,You can write to me direct in my email (soniaibrahimma@yahoo.com) so that i will send more of my photo to you and tell you more about me. ( soniaibrahimma@yahoo.com)