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

design pattern

 
Post new topic   Reply to topic    Smarty Forum Index -> Smarty Development
View previous topic :: View next topic  
Author Message
commando
Smarty Rookie


Joined: 10 Aug 2004
Posts: 7

PostPosted: Tue Aug 10, 2004 12:11 pm    Post subject: design pattern Reply with quote

I'm new to PHP (i'm a Java programmer by trade), and i'm learning PHP. I'm writing a little app to teach myself, and i'd like to check with an experienced php programmer if what i'm doing sounds ok.

When someone POSTs a form, any field that fails validation is added to an array called $errors, and the user is sent back to the page. The tpl uses this code to highlight the field in red if it's in the array:

Code:

{if array_search('website', $errors)}
  <font color="red">Manufacturer Website</font>
{else}
  Manufacturer Website
{/if}


I also want to pre-populate the fields they've already typed in, so they don't have to retype the whole form if they make one mistake. My approach for this is all the fields values are put into another array, the field name is the key and the value they submitted is the value. The tpl file will look up this array and populate the form with this. I'm having a little trouble with that last step, I posted about it here.

Does this design pattern seem ok? I tried vDaemon first, it was fine, but my debugger didn't like it.

Many thanks for any thoughts.

C
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Smarty Development All times are GMT
Page 1 of 1

 
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