Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Possible to generate a fieldset from properties array without using a Model
  • I know that Models have the ability to generate forms based on their properties arrays. Is there a way to do a similar thing without using a model?
  • Sure. The basis of the form generation is the fieldset object, you can use its methods to manually build a form by adding fields to it.

    If you want to automate it using another source of field information, look at what Observer_Validation::set_fields() does. Just don't ask me why it is there (= in that class)... ;-)

    For a more modern approach, you can use Which is what we use in our applications.
  • Okay. I knew about building forms via the Fieldset class. I'm looking for a way to do it where it essentially just has one big array set up similar to a model's properties array and pass it in to a function that generates the fieldset with all fields as specified in through the array.

    So there's no ready made solution for this it then. Since Observer_Validation::set_fields() seems to only work if you pass it a model from my tests so far, I'll need to create a function that takes in an array and builds it like I want.
  • HarroHarro
    Accepted Answer
    Yes, there isn't something ready made, as it depends very much on how that array would be structured, and what it contains, which is application specific. 

    But you can use set_fields() as a guidance, to see how it is done. 

Howdy, Stranger!

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

In this Discussion