Generating forms - XML or PHP?

Generating forms - XML or PHP?

am 12.04.2008 09:50:14 von webcm123

I need a solution for CMS. I would like to edit and create FORMS
easily, especially list of settings. Which is better and why?

$$ XML or HTML $$
Forms occur in View layer - in presentation file. To simplify editing
forms and to improve readability, webmasters use additional tags and
attributes, e.g. , , arrayname... The compiler of
templates changes XML code into (X)HTML with conditional expressions
in PHP and variables (until the template class doesn't compile
templates but parse them).

$$ PHP $$
Form fields and their properties are defined in PHP logic code. Form
class generates the HTML form. However, the class needs HTML code of
each

element - perhaps from template

Examples: http://code.bulix.org/so4zlh-66117

Re: Generating forms - XML or PHP?

am 12.04.2008 14:36:44 von Jerry Stuckle

WebCM wrote:
> I need a solution for CMS. I would like to edit and create FORMS
> easily, especially list of settings. Which is better and why?
>
> $$ XML or HTML $$
> Forms occur in View layer - in presentation file. To simplify editing
> forms and to improve readability, webmasters use additional tags and
> attributes, e.g. , , arrayname... The compiler of
> templates changes XML code into (X)HTML with conditional expressions
> in PHP and variables (until the template class doesn't compile
> templates but parse them).
>
> $$ PHP $$
> Form fields and their properties are defined in PHP logic code. Form
> class generates the HTML form. However, the class needs HTML code of
> each element - perhaps from template
>
> Examples: http://code.bulix.org/so4zlh-66117
>

Apples and oranges.

XML and HTML are scripting languages for sharing data. PHP is a
programming language used for processing data. They are two entirely
different things and used for different purposes.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Re: Generating forms - XML or PHP?

am 12.04.2008 15:04:13 von webcm123

You haven't understood me. :) Example of unclear code:


checked="checked" />

A lot of such constructions make the code unclear. Similar in pure
PHP:

'' ?> />

So I'm looking for a good solution for making s. There are 2 or
more methods - XML-based or PHP-based. Which is better and why?

XML-based - example of checkbox:


PHP-based:
$form = new Form('...');
$form -> set( /*fields, properties, etc. */ );
$template -> set('form', $form);

Re: Generating forms - XML or PHP?

am 12.04.2008 16:06:16 von Jerry Stuckle

WebCM wrote:
> You haven't understood me. :) Example of unclear code:
>
>
> checked="checked" />
>
> A lot of such constructions make the code unclear. Similar in pure
> PHP:
>
> > '' ?> />
>
> So I'm looking for a good solution for making s. There are 2 or
> more methods - XML-based or PHP-based. Which is better and why?
>
> XML-based - example of checkbox:
>
>
> PHP-based:
> $form = new Form('...');
> $form -> set( /*fields, properties, etc. */ );
> $template -> set('form', $form);
>

No, I didn't misunderstand you. However, you're confused about terminology.

There is no such thing as a "php based form". The form can be html or
xml, but not php.

It can be generated by PHP, Perl, ASP or a number of languages.

What you're talking about is not PHP based. It is object oriented
programming. This will generate html or xml statements. But that in
itself is not a form.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

OT Re: Generating forms - XML or PHP?

am 12.04.2008 16:32:00 von Pat Willener

> WebCM wrote:
>> You haven't understood me. :) Example of unclear code:
>>
>>
>> checked="checked" />
>>
>> A lot of such constructions make the code unclear. Similar in pure
>> PHP:
>>
>> >> '' ?> />
>>
>> So I'm looking for a good solution for making s. There are 2 or
>> more methods - XML-based or PHP-based. Which is better and why?
>>
>> XML-based - example of checkbox:
>>
>>
>> PHP-based:
>> $form = new Form('...');
>> $form -> set( /*fields, properties, etc. */ );
>> $template -> set('form', $form);
>>
>
> No, I didn't misunderstand you. However, you're confused about
> terminology.
> There is no such thing as a "php based form". The form can be html or
> xml, but not php.
>
> It can be generated by PHP, Perl, ASP or a number of languages.
>
> What you're talking about is not PHP based. It is object oriented
> programming. This will generate html or xml statements. But that in
> itself is not a form.

But that's not much of an answer; since I think I know where the OP is
coming from and was mildly interested, I read the thread; for nothing it
turns out. Do you ever make any positive posts with actual useful
suggestions? Or ferret out information you need to make a sensible
response?
--

Twayne

Open Office isn't just for wimps anymore;
OOo is a GREAT MS Office replacement
www.openoffice.org

Re: Generating forms - XML or PHP?

am 12.04.2008 16:50:47 von piotr

WebCM wrote:
> I need a solution for CMS. I would like to edit and create FORMS
> easily, especially list of settings. Which is better and why?
>
> $$ XML or HTML $$
> Forms occur in View layer - in presentation file. To simplify editing
> forms and to improve readability, webmasters use additional tags and
> attributes, e.g. , , arrayname... The compiler of
> templates changes XML code into (X)HTML with conditional expressions
> in PHP and variables (until the template class doesn't compile
> templates but parse them).
>
> $$ PHP $$
> Form fields and their properties are defined in PHP logic code. Form
> class generates the HTML form. However, the class needs HTML code of
> each element - perhaps from template
>
> Examples: http://code.bulix.org/so4zlh-66117

There are solutions like PEAR QuickForm or Zend_Form.
both provide some validation and filtering helpers,
for forms that are often displayed you can use some caching,
to make sure complete model is created only if the form is actually used.

It's also usefull to check phpclasses.org for ideas.

best regards
Piotr Nastaly

Re: Generating forms - XML or PHP?

am 12.04.2008 20:08:55 von Teh Riddler

On Apr 12, 7:50 am, Piotr wrote:
> WebCM wrote:
> > I need a solution for CMS. I would like to edit and create FORMS
> > easily, especially list of settings. Which is better and why?
>
> > $$ XML or HTML $$
> > Forms occur in View layer - in presentation file. To simplify editing
> > forms and to improve readability, webmasters use additional tags and
> > attributes, e.g. , , arrayname... The compiler of
> > templates changes XML code into (X)HTML with conditional expressions
> > in PHP and variables (until the template class doesn't compile
> > templates but parse them).
>
> > $$ PHP $$
> > Form fields and their properties are defined in PHP logic code. Form
> > class generates the HTML form. However, the class needs HTML code of
> > each element - perhaps from template
>
> > Examples:http://code.bulix.org/so4zlh-66117
>
> There are solutions like PEAR QuickForm or Zend_Form.
> both provide some validation and filtering helpers,
> for forms that are often displayed you can use some caching,
> to make sure complete model is created only if the form is actually used.
>
> It's also usefull to check phpclasses.org for ideas.
>
> best regards
> Piotr Nastaly

To possibly clearify the question. WebCM, you are unsure whether or
not to dynamically generate a XML for or a HTML form, correct?
So you would like to know which one (Between XML and HTML) is a better
fit for your project?

The easiest thing to do is probably create classes for both. It would
be rather simple. Then you would have options for how many checkboxes,
input fields, or textareas you wanted, and all you would have to do is
arrange your code to fit the output of the form.

Example:
$nf = newForm();
$nf->getInputField('User:');
$nf->getInputField('Pass:');
$nf->getSubmitField(1);

Or you could have it so
$nf-getInputFields(1);
$nf-getTextareaFields(1);
$nf-getCheckboxes(5);

And then just name each one after you get it if you used the second
method.
You could also write one separate for XML.
I'm not an expert at OOP, but I think this might possible be what
you're looking for.
I would suggest research more OOP if you really want to get into it.
A good place to start is http://www.killerphp.com/tutorials/object-oriented-php/

Re: OT Re: Generating forms - XML or PHP?

am 12.04.2008 21:28:24 von Jerry Stuckle

Twayne wrote:
>> WebCM wrote:
>>> You haven't understood me. :) Example of unclear code:
>>>
>>>
>>> checked="checked" />
>>>
>>> A lot of such constructions make the code unclear. Similar in pure
>>> PHP:
>>>
>>> >>> '' ?> />
>>>
>>> So I'm looking for a good solution for making s. There are 2 or
>>> more methods - XML-based or PHP-based. Which is better and why?
>>>
>>> XML-based - example of checkbox:
>>>
>>>
>>> PHP-based:
>>> $form = new Form('...');
>>> $form -> set( /*fields, properties, etc. */ );
>>> $template -> set('form', $form);
>>>
>> No, I didn't misunderstand you. However, you're confused about
>> terminology.
>> There is no such thing as a "php based form". The form can be html or
>> xml, but not php.
>>
>> It can be generated by PHP, Perl, ASP or a number of languages.
>>
>> What you're talking about is not PHP based. It is object oriented
>> programming. This will generate html or xml statements. But that in
>> itself is not a form.
>
> But that's not much of an answer; since I think I know where the OP is
> coming from and was mildly interested, I read the thread; for nothing it
> turns out. Do you ever make any positive posts with actual useful
> suggestions? Or ferret out information you need to make a sensible
> response?

Yep. And this was helpful. Maybe it isn't what he wants, but before he
can ask what he needs to know, he needs to understand the differences
between html, xml and PHP.

You should learn something about what you're talking about before you
start criticizing those who know more than you.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Re: Generating forms - XML or PHP?

am 12.04.2008 23:53:48 von Manuel Lemos

Hello,

on 04/12/2008 04:50 AM WebCM said the following:
> I need a solution for CMS. I would like to edit and create FORMS
> easily, especially list of settings. Which is better and why?
>
> $$ XML or HTML $$
> Forms occur in View layer - in presentation file. To simplify editing
> forms and to improve readability, webmasters use additional tags and
> attributes, e.g. , , arrayname... The compiler of
> templates changes XML code into (X)HTML with conditional expressions
> in PHP and variables (until the template class doesn't compile
> templates but parse them).
>
> $$ PHP $$
> Form fields and their properties are defined in PHP logic code. Form
> class generates the HTML form. However, the class needs HTML code of
> each element - perhaps from template
>
> Examples: http://code.bulix.org/so4zlh-66117

If you define forms as HTML or XML you are mixing application logic with
presentation logic.

A better approach is to define and process forms only as application
logic, and then have a component to generate forms HTML from the forms
definition, eventually using PHP embedded in HTML, Smarty or other type
of templates to define presentation logic.

You can achieve that with this forms generation and validation class.

http://www.phpclasses.org/formsgeneration


--

Regards,
Manuel Lemos

PHP professionals looking for PHP jobs
http://www.phpclasses.org/professionals/

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

Re: Generating forms - XML or PHP?

am 13.04.2008 03:40:15 von Jerry Stuckle

Manuel Lemos wrote:
> Hello,
>
> on 04/12/2008 04:50 AM WebCM said the following:
>> I need a solution for CMS. I would like to edit and create FORMS
>> easily, especially list of settings. Which is better and why?
>>
>> $$ XML or HTML $$
>> Forms occur in View layer - in presentation file. To simplify editing
>> forms and to improve readability, webmasters use additional tags and
>> attributes, e.g. , , arrayname... The compiler of
>> templates changes XML code into (X)HTML with conditional expressions
>> in PHP and variables (until the template class doesn't compile
>> templates but parse them).
>>
>> $$ PHP $$
>> Form fields and their properties are defined in PHP logic code. Form
>> class generates the HTML form. However, the class needs HTML code of
>> each element - perhaps from template
>>
>> Examples: http://code.bulix.org/so4zlh-66117
>
> If you define forms as HTML or XML you are mixing application logic with
> presentation logic.
>

Yes, that's true. But then again, that's what PHP is excellent at.

> A better approach is to define and process forms only as application
> logic, and then have a component to generate forms HTML from the forms
> definition, eventually using PHP embedded in HTML, Smarty or other type
> of templates to define presentation logic.
>

Not necessarily. It depends on what you need done. And PHP embedded in
HTML is often NOT the best way to do something.

> You can achieve that with this forms generation and validation class.
>
> http://www.phpclasses.org/formsgeneration
>
>

Spamming your crappy classes again? You should at least warn people
that these are your classes, and therefore your opinion is far from
unbiased.

But you never have done that. It is the only way you can get someone to
your your junk?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================