php - building dynamic form in cakephp
I'm trying to build a form dynamically based on the field and its definitions stored in a XML file. In my xml, I have defined 1 checkbox with some label and 1 textfield with some label.
How do I build a form dynamically based on what I have in my xml.
I dont want to create any models.
Not Quite sure where you're going with this or why it's needed. I've built dynamic forms from db definitions, (so that adding/removing fields would have a front end, but don't see why one would do that from an xml file.) Nevetheless, here's the basic idea:
In a Controller function
In a view:
Thats the basic idea, in practice I would wrap those array options in !empty() checks, and depending on your xml structure and fields used you'll need to make adjustments to the conditional (perhaps implementing a switch case to handle specific formatting.) This clearly assumes your table or model is set up to handle any of the fields set.