Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7537453
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T06:51:22+00:00 2026-05-30T06:51:22+00:00

I am building a PHP application with CakePHP 2 . I need to have

  • 0

I am building a PHP application with CakePHP 2.
I need to have page where a form is displayed.

The form has to be dynamically generated based on configurations stored in a database.

For example :

Database content :

{
 {name:"Username",type:"text",label:"Username",validation:("required","minlength:6")},
 {name:"Password",type:"password",label:"Password",validation:("required","minlength:6")},
 {name:"Submit",type:"submit",value:"submit"}
}

I want some config like this (Format Negotiable) to be stored in a database and based on that a html form would be generated at run-time. If the config is changed at run time the form would also change.
I understand that cakePHP has a form generation component.

So my question is How do I actually get from a config stored in a database to cakePHP form generator and then to the page ?

I was considering the eval() function, but I read that it was not really safe, and I am trying to avoid it if possible.

PS:

I will be using mongodb for storing the data obtained from the form.

The way that the form configuration is stored in the database is flexible,I am thinking of storing it as a string but that is negotiable.

I am also open to storing the configuration for the form in any database be it a RDBMS or a NoSQL database.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T06:51:24+00:00Added an answer on May 30, 2026 at 6:51 am

    Parse the config from the database (use a data serialization function like serialize(), json_encode(), or an xml serializer.. whatever is convenient) and build the form using http://book.cakephp.org/2.0/en/core-libraries/helpers/form.html

    // Psuedo-code
    $fields = array(
      'fields' => array(
        'name' => 'username',
        'type' => 'text',
        'label' => 'Username',
        'validation' => array('...validation config...'),
      )
    );
    
    foreach($fields as $formOptions) {
      echo $this->Form->input($formOptions['name'], array('label' => $formOptions['label'])); 
    }
    

    And so on..

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We are currently building a web-based application that has the need to associate a
I'm building a php based application for a client to enter in addresses for
I'm building a PHP web application and need to know what the current date/time
Background: I'm building an automated test framework for a PHP application, and I need
I'm building an application which is Client (C#) & Server (PHP) based application. I
I'm building a PHP application framework where all pages are created dynamically such as:
I'm building a php application that will have many modules/plugins. The issue is that
I am currently building a PHP application using the MVC pattern. I have implemented
I am building a PHP comet based application. Which web server should I use
I am in the process of building a PHP/MySql database application which could have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.