Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.

SmartyFormtool: a javascript tool for your forms
Goto page Previous  1, 2
 
Post new topic   Reply to topic    Smarty Forum Index -> Add-ons
View previous topic :: View next topic  
Author Message
TuMadre
Smarty Rookie


Joined: 13 Jun 2004
Posts: 12

PostPosted: Tue Jun 15, 2004 10:55 am    Post subject: Reply with quote

K, now moving items between the two works fine. On submitting the form, the two save vars are empty (colors5_save and colors6_save).

http://games.xs4all.nl/tester.php

tester.php
[php:1:ca7c2243e5]<?php

// Require basic site files

require("misc/bans/include/config.inc.php");
$colors = array(red,yellow,blue,orange,purple,green,brown,black,white);

function display_post_get() {
if ($_POST) {
echo "Displaying POST Variables: <br> \n";
echo "<table border=1> \n";
echo " <tr> \n";
echo " <td><b>result_name </b></td> \n ";
echo " <td><b>result_val </b></td> \n ";
echo " </tr> \n";
while (list($result_nme, $result_val) = each($_POST)) {
echo " <tr> \n";
echo " <td> $result_nme </td> \n";
echo " <td> $result_val </td> \n";
echo " </tr> \n";
}
echo "</table> \n";
}
if ($_GET) {
echo "Displaying GET Variables: <br> \n";
echo "<table border=1> \n";
echo " <tr> \n";
echo " <td><b>result_name </b></td> \n ";
echo " <td><b>result_val </b></td> \n ";
echo " </tr> \n";
while (list($result_nme, $result_val) = each($_GET)) {
echo " <tr> \n";
echo " <td> $result_nme </td> \n";
echo " <td> $result_val </td> \n";
echo " </tr> \n";
}
echo "</table> \n";
}
}

if (isset($_POST['submit'])) {
display_post_get();
}

$smarty = new dynamicPage;
$smarty->assign("this",$_SERVER['PHP_SELF']);
$smarty->assign("colors",$colors);

$smarty->display('tester.tpl');

?>
?>[/php:1:ca7c2243e5]

tester.tpl
Code:
{formtool_init src="/formtool.js"}

<table border=1>
   <form name='colors' method='post' action='{$this}'>
   <tr>
   <td valign="top">
      <select name="colors5[]" multiple size="10">
      {html_options values=$colors output=$colors}
      </select>
      <input type="hidden" name="colors5_save">
   </td>
   <td align="center">
      {formtool_moveall from="colors5[]" to="colors6[]" button_text=">>"  save_from="colors5_save" save_to="colors6_save"}<br />
      {formtool_move from="colors5[]" to="colors6[]" button_text=">" save_from="colors5_save" save_to="colors6_save"}<br />
      {formtool_move from="colors6[]" to="colors5[]" button_text="<" save_from="colors5_save" save_to="colors6_save"}<br />
      {formtool_moveall from="colors6[]" to="colors5[]" button_text="<<" save_from="colors5_save" save_to="colors6_save"}
   </td>
   <td valign="top">
      <select name="colors6[]" multiple size="10">
      </select>
      <input type="hidden" name="colors6_save">
   </td>
   </tr>
   
</table>

<input type="submit" name="submit" value="submit">
</form>
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7365
Location: Lincoln Nebraska, USA

PostPosted: Tue Jun 15, 2004 2:19 pm    Post subject: Reply with quote

Hmm, it seems I don't have the latest version of formtool.js in the distribution Sad

Grab the CVS version, let me know if that works:

cvs -d :pserver:anonymous@cvs.phpinsider.com:/export/CVS login
cvs -d :pserver:anonymous@cvs.phpinsider.com:/export/CVS checkout SmartyFormtool
Back to top
View user's profile Send private message Visit poster's website
TuMadre
Smarty Rookie


Joined: 13 Jun 2004
Posts: 12

PostPosted: Tue Jun 15, 2004 3:09 pm    Post subject: Reply with quote

Checked out latest formtool.js: still the same problem...
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7365
Location: Lincoln Nebraska, USA

PostPosted: Tue Jun 15, 2004 6:55 pm    Post subject: Reply with quote

Did you use the plugins from CVS too?
Back to top
View user's profile Send private message Visit poster's website
TuMadre
Smarty Rookie


Joined: 13 Jun 2004
Posts: 12

PostPosted: Tue Jun 15, 2004 7:23 pm    Post subject: Reply with quote

mohrt wrote:
Did you use the plugins from CVS too?


Tried that now... It doesn't fix the problem. Besides that, it also introduces JS errors when moving items from colors5 to colors6 (allthough it *does* move them).

http://games.xs4all.nl/tester.php
Back to top
View user's profile Send private message
carnalito
Smarty n00b


Joined: 16 Jun 2004
Posts: 1

PostPosted: Wed Jun 16, 2004 7:27 pm    Post subject: Reply with quote

Hi there,

just add the following:

function.formtool_move.php (after line 31 as new lines):
Code:
$_save_from = $params['save_from'];
$_save_to   = $params['save_to'];


formtool.js (search and replace the following existing functions):
Code:
function formtool_move(field1,field2,field1_save,field2_save) {
    formtool_createobj(field1,field2);
    formtool_move_element();
    formtool_move_save(field1,field1_save);
    formtool_move_save(field2,field2_save);
}
function formtool_moveall(field1,field2,field1_save,field2_save) {
    formtool_createobj(field1,field2);
    formtool_move_all();
    formtool_move_save(field1,field1_save);
    formtool_move_save(field2,field2_save);
}


After that it worked for me like a charm.

Regards from Germany

Carnalito
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7365
Location: Lincoln Nebraska, USA

PostPosted: Wed Jun 16, 2004 8:13 pm    Post subject: Reply with quote

Thanks for looking into this....

The first one is an obvious error in the PHP code, the second one doesn't make sense to me... There is no 'formtool_move_save' javascript function. Those should work as-is (?)

I committed the new function.formtool_move.php in CVS.
Back to top
View user's profile Send private message Visit poster's website
moggen
Smarty n00b


Joined: 08 Feb 2005
Posts: 2

PostPosted: Tue Feb 08, 2005 3:37 pm    Post subject: No initial values in the second select Reply with quote

Hi...
I have two smarty html_options fields. One to move from and one to move to.
Each of these fields is initialized with values when the page loads.

The problem is this:
The initial values in the second option field is only saved in the colors6_save when i first move objects to this box. I realize this is beacuse the "save" function is fired, but how can u set this to save at page load...?

consider the following example

<table border=1>
<tr>
<td valign="top">
<select name="colors5[]" multiple size="10">
{html_options values=$colors output=$colors}
</select>
<input type="hidden" name="colors5_save">
</td>
<td align="center">
{formtool_moveall from="colors5[]" to="colors6[]" button_text=">>" save_from="colors5_save" save_to="colors6_save"}<br />
{formtool_move from="colors5[]" to="colors6[]" button_text=">" save_from="colors5_save" save_to="colors6_save"}<br />
{formtool_move from="colors6[]" to="colors5[]" button_text="<" save_from="colors5_save" save_to="colors6_save"}<br />
{formtool_moveall from="colors6[]" to="colors5[]" button_text="<<" save_from="colors5_save" save_to="colors6_save"}
</td>
<td valign="top">
<select name="colors6[]" multiple size="10">
{html_options values=$colors2 output=$colors2}
</select>
<input type="hidden" name="colors5_save">
<input type="hidden" name="colors6_save">
</td>
</tr>
</table>

the values loaded by the $colors2 variable is not saved until you actually use the buttons that fires the formtool functions...

Any thoughts on this one..?
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7365
Location: Lincoln Nebraska, USA

PostPosted: Tue Feb 08, 2005 5:51 pm    Post subject: Reply with quote

look into the formtool_save function.
Back to top
View user's profile Send private message Visit poster's website
moggen
Smarty n00b


Joined: 08 Feb 2005
Posts: 2

PostPosted: Tue Feb 08, 2005 6:40 pm    Post subject: Reply with quote

Thank you for fast reply, although I should have figured that one out for myself... Embarassed

I would like to use this opportunity to congratulate you guys, Monte and Andrei, for a great piece of software... Made my life a whole lot easier
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Add-ons All times are GMT
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP