[Challenge ] - Create a Form Description Language

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
joeynovak
Forum Commoner
Posts: 26
Joined: Sun May 10, 2009 11:09 am

[Challenge ] - Create a Form Description Language

Post by joeynovak »

Hey Guys,

The challenges are awesome, so I thought I'd create one that might be fun.

The Challenge, Create a form description language, such that, the following input, will create the following output (and pull values for inputs from the supplied array):

(DEFAULT VALUES)

Code: Select all

 
$a = array();
$a['firstname'] = 'Jim';
$a['lastname'] = 'Bob';
 
(FORM DESCRIPTION)

Code: Select all

 
input text firstname 
input text lastname
 
(OUTPUT)

Code: Select all

 
<input type="text" name="firstname" value="Jim">
<input type="text" name="lastname" value="Bob">
 
I've got a few ideas for other challenges that build off of this one, so bonus points go for code quality.
SimonMayer
Forum Commoner
Posts: 32
Joined: Wed Sep 09, 2009 6:40 pm

Re: [Challenge ] - Create a Form Description Language

Post by SimonMayer »

I think I've got something that will do this, but I'm not entirely sure I've understood it correctly, so please could you clarify exactly what you want:
Do you mean that for every key in the array, an input box should be created with the <input> name of the array key and the <input> value of the array value?

If that is what you want, I've done it. If not, please could you provide more details?

Also, do you want me to post the code here or pm it to you?
joeynovak
Forum Commoner
Posts: 26
Joined: Sun May 10, 2009 11:09 am

Re: [Challenge ] - Create a Form Description Language

Post by joeynovak »

The array key would be too easy....

The challenge is to create the form based on the text description.

Just post it here so we can see each others code.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: [Challenge ] - Create a Form Description Language

Post by requinix »

How about XML? For data like that XML is a great solution.

But then it starts resembling the HTML used to draw it.
User avatar
McInfo
DevNet Resident
Posts: 1532
Joined: Wed Apr 01, 2009 1:31 pm

Re: [Challenge ] - Create a Form Description Language

Post by McInfo »

YAML

Edit: This post was recovered from search engine cache.
Post Reply