Ciao a tutti sto creando una classe di form... ho appena iniziato a farla.. ma subito riscontro un errore. Questa è la bozza della classe:

codice:
class form
	{
		protected  $elements = array();
		
		function addElement($element)
		{
			$this->$elements[] = $element;
			
		}
		
		function field($properties)
		{
			$element = json_decode($properties,true);
			return $element;
		}
		
		function printForm()
		{
			print_r($elements['field']);
		}
	}
mentre questa è la pagina che la richiama:

codice:
require('phpform.class.php');
	$f = new form();
	$txtNome = $f->field('
			{
				"type":"text",
				"width":"200px"
			}
				');

	$f->addElement($txtNome);
	$f->printForm();
mi restituisce il seguente errore:
Fatal error: Cannot use [] for reading in phpform.class.php on line 8

Qualcuno sa aiutarmi?

Grazie in anticipo