Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Dealing with forms - displaying errors
  • I want to display a form, do some validation, and display any errors next to the fields that are in error. There seem to be two ways to handle forms. The way oil does it is to manually build the form as individual elements. The individual elements are then validated in a validation object in the controller. This validation object is constructed separately and independently of the form itself. The other way seems to be using a fieldset, which allows a form to be constructed in the controller and passed into the template for rendering. This makes more sense to me, as it means the validation can (in theory) be handled in one place and no duplicated across the controller and template. Is this a fair description of the approaches to form construction? Next it I would look at displaying errors against the form elements that are in error. Is there a way "off the shelf" to do this? For each element in error, I'm guessing it would be wrapped in an "error" div, and the validation error message displayed in another html element of some sort. Is this kind of thing built-in to FuelPHP, or would I need to code for it manually? -- Jason
  • here is a simple application i have done when i was learning it.I dont use field set or oil . Hope it may help you to show the error in the validation.
    https://github.com/samitrimal/mod-cms
  • Thanks. It is good to see how Fuel works in practice. You have hand-coded the error message handling into the forms, as I have ended up doing. I was just hoping (actually, fully expecting, from a modern framework) there to be a more elegant way to handle it. And perhaps there is, but I'm sure it will need some core class over-riding and a better understanding of how this framework works. Thanks -- JJ

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion