Page 1 of 1

[Challenge ] - Create a Form Description Language

Posted: Sat Sep 12, 2009 1:09 pm
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.

Re: [Challenge ] - Create a Form Description Language

Posted: Sat Sep 12, 2009 2:58 pm
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?

Re: [Challenge ] - Create a Form Description Language

Posted: Sat Sep 12, 2009 3:41 pm
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.

Re: [Challenge ] - Create a Form Description Language

Posted: Sat Sep 12, 2009 4:44 pm
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.

Re: [Challenge ] - Create a Form Description Language

Posted: Sat Sep 12, 2009 5:34 pm
by McInfo
YAML

Edit: This post was recovered from search engine cache.