Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Formsess: forms handling with Smarty
Goto page 1, 2  Next
 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Add-ons
View previous topic :: View next topic  
Author Message
katana
Smarty Rookie


Joined: 17 Apr 2003
Posts: 26
Location: France

PostPosted: Sat Apr 19, 2003 2:50 pm    Post subject: Formsess: forms handling with Smarty Reply with quote

A few month ago, i had sent a message on the mailing list about a sort of "forms framework" i had written to work with Smarty. It has been developped a little since then, used by 2 or 3 developers, and I think I can offer it here again.

The website is not back yet since my personal server had some problems and is still sleeping under the desk... if it's requested I'll setup a website again.

First, my app. has bugs, missing features, no or not enough documentation. If you can do with it, you can read further on Smile

Formsess is a set of plugins, prefilters and php classes / functions used to handle forms and forms data across pages when using smarty.
A set of custom XHTML tags, very similar to HTML Form tags, let you create forms in your templates. The data from each form is then handled by a class that will be used to store the data in a session dataspace, validate the data, and so on.
In fact, you can write all your forms without caring about the "value" "selected" or "checked" part, all of that is handled in the PHP script.

You can download the files needed by formsess here:
http://www.katana-inc.com/formsess/formsess.zip

There is no README nor INSTALL files, i've gotta create them (in fact a lot of work was done but my CVS repository was LOST).
Anyway, the setup is not complex: keep the libs directory as is, but you can rename it (a little like smarty's libs dir). The Smarty_fs file contains the definition of a class that extends smarty and is used to automatically include formsess' files. It's not mandatory but of course it's cleaner that way.
The prepend file creates the Smarty_fs object and assigns 2 paths.
And finally, the config.inc.php file is included by prepend.php and contains 2 config vars.
This is my own file setup, you can change it to whatever you want, as long as the logic is the same, formsess will just work the same way.

I have written a quick sample script / template. It has not beed tested, sorry, i'll fix that later.
You can find the sample files in the archive in /samples/. It just displays a basic form with several elements, and when data is submited, it saves the values then redirects to the form.

Ask here if you need help, I'll answer as soon as possible.
If you find bugs I'll be glad to fix them.
And if you have suggestions, I'll listen.

Hope it helps.

Edit:
An anonymous CVS is now available:
CVSROOT=:pserver:anonymous@cvs.phpedit.net:/cvs/formsess
no password
I'm not sure what I'm doing is interesting but I'll keep on working on it Smile


Last edited by katana on Mon Apr 21, 2003 6:41 am; edited 1 time in total
Back to top
View user's profile Send private message MSN Messenger
dak
Smarty n00b


Joined: 16 Apr 2003
Posts: 1
Location: Russia, Moscow

PostPosted: Sat Apr 19, 2003 7:52 pm    Post subject: Reply with quote

Can you translate all comments in all files from french to english. For exmaple in files: Smarty_fs.class.php and formsess.class.php and may be in another files?
Back to top
View user's profile Send private message
katana
Smarty Rookie


Joined: 17 Apr 2003
Posts: 26
Location: France

PostPosted: Sat Apr 19, 2003 8:00 pm    Post subject: Reply with quote

Huhu sorry; yes, of course. I've developed the application itself in english so that it can be easily distributed, but these files were originally written for another project.

I'm currently working on setting up a CVS for the project, it should be up with an anonymous acces on monday.

And I'll update the zip file with "translated" files.
Back to top
View user's profile Send private message MSN Messenger
ronan
Smarty n00b


Joined: 18 Apr 2003
Posts: 4

PostPosted: Sun Apr 20, 2003 9:52 am    Post subject: Reply with quote

I have not looked at your project for the moment. I guess you know that there are already some scripts which offer the same features:
- html forms generation and validation written by Manuel Lemos http://www.phpclasses.org/browse.html/package/1.html
- smarty forms http://freshmeat.net/projects/smartyform/

Can you explain what are the differences between your project and these ?

Regards,

Ronan
Back to top
View user's profile Send private message Send e-mail
katana
Smarty Rookie


Joined: 17 Apr 2003
Posts: 26
Location: France

PostPosted: Sun Apr 20, 2003 10:17 am    Post subject: Reply with quote

In fact i first developped a simple form validation class, then extended it to store the data between pages then added the direct interaction between the templates and the data. So it was written for me, and now that it looks usable i just want to share it.

Now for the two scripts you talk about: i didn't write this to make something better than the other scripts. I wanted something that allowed good interaction with smarty. What I can say about formsess is that it makes the work for templates designer very easy, without having to learn any (or very few) tags, since the tags used by formsess are almost identical to classical HTML tags. I think that the main difference is a philosophical one Smile
Back to top
View user's profile Send private message MSN Messenger
muppie
Smarty Rookie


Joined: 27 Apr 2003
Posts: 20

PostPosted: Sun Apr 27, 2003 4:52 pm    Post subject: Reply with quote

I developed my Form class... and thought about making it a smarty plugin.... however I ended up with something like this:

$smarty->assign('form', $form->build());

and in the template:

Code:


{if $form.finished}

Dear {$form.values.first_name}, thank you for submitting your details.

{else}

{$form.start}
<table>
<tr>
  <td>{$form.labels.first_name}</td>
  <td>{$form.controls.first_name}</td>
</tr>
<tr>
  <td>{$form.prev}</td><td align="right">{$form.next}</td>
</tr>
</table>
{$form.end}

{/if}


So it ended up not needing any special smarty plugins. Just plain old smarty support for nested arrays.

The form class supports multiple page handling with next/previous, data validation (by using as many callback functions as needed), possible logic in determining which page to go when user click next for example to skip a page if user clicks "pay with credit card" - it will go to CC page otherwise it will display where to send the check.

If there is any error in the form, {$form.labels.first_name} for example will be shown red, or other means to indicate error. Combined with smarty it becomes very flexible depending on how you want to display things around.
Back to top
View user's profile Send private message
muppie
Smarty Rookie


Joined: 27 Apr 2003
Posts: 20

PostPosted: Sun Apr 27, 2003 5:00 pm    Post subject: Reply with quote

ronan wrote:
- html forms generation and validation written by Manuel Lemos http://www.phpclasses.org/browse.html/package/1.html
- smarty forms http://freshmeat.net/projects/smartyform/


Manuel Lemos' is nice with javascript validators too, but I found it very hard to use / set up a form or even to learn it. If you think I'm wrong please correct me.

I've never seen smartyforms closely... isn't it lemos' wrapper for smarty?

I looked hard for form generation/validation class before I wrote mine. There's HTML_OOH_FORM and HTML_QuickForm in Pear. Quick Form wasn't flexible enough (it defines the output html) and OOH was.... hard to use (for me)
Back to top
View user's profile Send private message
jorgerpo
Smarty n00b


Joined: 15 Jun 2003
Posts: 3

PostPosted: Thu Jun 26, 2003 6:18 pm    Post subject: Reply with quote

Your approach seems great muppie. Would you like to share it?
Back to top
View user's profile Send private message
katana
Smarty Rookie


Joined: 17 Apr 2003
Posts: 26
Location: France

PostPosted: Fri Jul 04, 2003 9:41 am    Post subject: Reply with quote

Sorry, for some reason I didn't get an email for your reply.

The "official" website for formsess is http://www.katana-inc.com/formsess/

It is still missing a solid documentation, but there is one already. Don't hesitate to ask if you have any question.
Back to top
View user's profile Send private message MSN Messenger
katana
Smarty Rookie


Joined: 17 Apr 2003
Posts: 26
Location: France

PostPosted: Thu Aug 21, 2003 7:38 pm    Post subject: Reply with quote

In order to keep the post up to date, I'll add a new version was released (2.0.0 RC2) and a real documentation is now available on the website (http://www.katana-inc.com/formsess)

Several nice features are being added, like dynCalendar integration (DHTML calendar from phpguru.org which allows quick & easy selection of a date for a html_select_date field)
Back to top
View user's profile Send private message MSN Messenger
muppie
Smarty Rookie


Joined: 27 Apr 2003
Posts: 20

PostPosted: Sat Sep 13, 2003 1:19 pm    Post subject: Reply with quote

jorgerpo wrote:
Your approach seems great muppie. Would you like to share it?
Unfortunately I am not planning to release this class.

Last edited by muppie on Sun Sep 28, 2003 1:13 pm; edited 1 time in total
Back to top
View user's profile Send private message
Justin
Smarty Regular


Joined: 07 May 2003
Posts: 38
Location: Vilnius, Lithuania

PostPosted: Sun Sep 28, 2003 12:50 pm    Post subject: Reply with quote

I spent all day with formsess and smarty.. and what can I say.. it's great!
waiting for new formsess versions and features Smile
_________________
http://www.baubas.net
Back to top
View user's profile Send private message Visit poster's website
katana
Smarty Rookie


Joined: 17 Apr 2003
Posts: 26
Location: France

PostPosted: Fri Oct 03, 2003 7:25 am    Post subject: Reply with quote

Whoa, thanks a lot justin. That's the kind of reply that gives you the will to develop Smile

Can I use your post as a testimony on the site ? Smile
Back to top
View user's profile Send private message MSN Messenger
Justin
Smarty Regular


Joined: 07 May 2003
Posts: 38
Location: Vilnius, Lithuania

PostPosted: Fri Oct 03, 2003 9:50 am    Post subject: Reply with quote

katana wrote:
Can I use your post as a testimony on the site ? Smile

yes:)

now I'm trying to find a solution, how to make error message multilanguage.. have you any ideas?
_________________
http://www.baubas.net
Back to top
View user's profile Send private message Visit poster's website
katana
Smarty Rookie


Joined: 17 Apr 2003
Posts: 26
Location: France

PostPosted: Fri Oct 03, 2003 10:04 am    Post subject: Reply with quote

I usually use Smarty configuration files for multilanguage, so using:
<fs:validate field="fieldname" check="empty" message="{#errormessage_fieldname_empty#}" />
would work.

However, there is something I need to fix with quotes escaping at the moment, so you'd better avoid single quotes inside the messages Smile
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Add-ons All times are GMT
Goto page 1, 2  Next
Page 1 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