PHP Classes

Easier AddInput and AddLabelPart

Recommend this page to a friend!

      PHP Forms Class with HTML Generator and JavaScript Validation  >  All threads  >  Easier AddInput and AddLabelPart  >  (Un) Subscribe thread alerts  
Subject:Easier AddInput and AddLabelPart
Summary:Using a string as argument, with default options
Messages:2
Author:Sebastian Wais
Date:2006-09-27 13:18:50
Update:2006-09-27 17:47:27
 

  1. Easier AddInput and AddLabelPart   Reply   Report abuse  
Picture of Sebastian Wais Sebastian Wais - 2006-09-27 13:18:50
Hi Manuel

I was wandering if is posible to make easier to use this class by fgivin a string and assuming the more common options.

For Example
AddInput('any_input')

Could be parsed as the same as
AddInput(array(
'name' => 'any_input',
'id' => 'any_input',
'type' => 'text',
'label' => 'Any Input'
))

just assuming the strings as text, using the string for id and name and replacing "_" for " ", and ucwords for presentation...

Maybe, if its posible, if this input "WasSubmitted" also getting the value.
And maybe also assume it is a mandatory field.

I think this is the most common input in any form, so it would be much easier and faster.


Also I had the same idea for AddLabelPart, 'cause I usually use
AddLabelPart(array("FOR" => "field_name"))

It could be
AddLabelPart("field_name")

Thanks

  2. Re: Easier AddInput and AddLabelPart   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2006-09-27 17:47:27 - In reply to message 1 from Sebastian Wais
What you want can be achieved mostly with additional functions, rather than replacements. Any changes need to be backwards compatible to not break current developers' code.

I could add such functions to the current class, but I am avoiding adding more code to the class as it is already too large. So, for now, I only add new features. What you want is just a different interface for the same functions, not really new features. I hope you understand.

I suggest that you create your own sub-class of the forms class and add your alternative interface functions. This way you can have the interface you would like without increasing further the size of the main class.