puting forms into a helper..

Hi there, just looking for some advice on best practice..

I would like to move my forms out of my views to clear things up a

I was thinking of creating a UDF in the include folder which would
contain all the different forms, for example

    <!---Add artist Form--->
   <cffunction name="showArtistForm" output="false" returntype="string"
access="public" hint="allow user to insert new artist">

   <!---Artist Id Argument--->
   <cfargument name="formAction" required="yes" type="any" hint="action
variable for form">

   <cfset addArtistForm = '<form name="setArtName"

                                       <legend>edit artist</legend>
                                     <label for="artist name">artists
                              <input name="name"
                                <input type="submit"
                     value="submit" />
                               <!---Hidden form field--->
                                <input name="name_art"
                            value="#rc.name_art#" />


      <cfreturn addArtistForm>


Then i could call the form in the view like so...


Is this best practise? Or maybe I should move forms into seperate
viewlets to clear things up?


Not sure about best practice, but all of my forms are views in a ‘forms’ folder. Then I use RenderView(‘forms/forminclude’) within my base view.

so you have a separate form in each seperate view in the 'forms'

Do you execute any events within these form views?



Keep it simple. So create a view for a form, maybe a view which
renders multiple views etc.
Personally, I would never use a cffunction to generate a form for me.



I don’t know what you mean by executing events within my views. But yes, I keep each of my forms in a separate view template. This way I can re-use them. For example, I have a ‘sign up’ form that is included on the homepage of my site, and there is also a ‘sign up’ page. I use renderView(‘forms/signup’) in both places. I think you hit the nail on the head with ‘viewlets’.

In viewlets...you can execute events...


<cfset runEvent(event='viewlets.artistForm'.private=true)>

In case you need to use some query variables in the forms hidden form
fields etc, etc..

Just wondered if you did this

Yes, this is the route I am taking..