top | item 5888818

(no title)

sashahart | 12 years ago

I'm curious about 'field helpers,' can you point to a page or briefly describe the difference?

discuss

order

mattchew|12 years ago

Sure, I mean helpers for the template/view that make it easier (syntax, data binding, validations) to render a HTML form widget. Instead of defining your form as a unit in app code, you manage the form fields in the view/template. For my money, this is much more intuitive and flexible.

It's common in other web frameworks. At least Codeigniter, Ruby on Rails, and ASP.NET MVC use this approach:

http://ellislab.com/codeigniter/user-guide/helpers/form_help...

http://guides.rubyonrails.org/form_helpers.html

http://msdn.microsoft.com/en-us/library/dd410596(v=vs.100).a...

lojack|12 years ago

Not 100% sure this is what mattchew was talking about, but instead of defining the form and then rendering the form field by doing something like this:

> {{ form.thefield }}

You would instead simply define the model and render the form field with something like this:

> {{ model.thefield | render_input }}

Or, if you had a regular Form (i.e. not a ModelForm) you would do something like this:

> {{ render_input:name="field_name" }}

And if you wanted validation or something, you'd need to create your own render_* methods to perform that validation.