Frontend revisited

Dan Rossi <liveuser-zu2dZaOKXTSc5qR/[email protected]>
Newsgroups gmane.comp.php.pear.liveuser
Message-ID <[email protected]>
I am currently building a frontend for liveuser as i've prob said 
before and learning the API at the same time. I have some ideas to 
build the forms dynamically, I have managed to get some useful 
variables from the perm which can help build the form using quickforms. 
I also had another idea of generating dataobjects and using FormBuilder 
which i use for other projects and is extremely useful. Here is an idea 
I have mocked up to build the form, I reckon the dataobjects is a 
better way this may not be so efficient, what it does is tries to find 
the primary key and hides it in the form for editing, its half baked 
and not complete. lemme know if anyone has built a proper frontend so 
i'm not wasting my time here :)

$result = $this->admin->perm->getApplications($params);

function getForm($result)
	{
		require_once 'HTML/QuickForm.php';
		$form = new HTML_QuickForm('liveuser', 'post');
		
	
		$db = $this->admin->perm->_storage->dbc;
		if (method_exists($db,"tableInfo()")) {
			
		} else {
			$db->loadModule('Reverse');
			$defs = $db->reverse->tableInfo('liveuser_applications');
			$fieldsToRender = array();
			$fieldsToHide = array();
			foreach ($defs as  $t) {
				 if (!preg_match("/primary_key/",rawurldecode($t[flags]))) {
				 	array_push($fieldsToRender,$t[name]);	
				 } else {
				 	array_push($fieldsToHide,$t[name]);	
				 }
			}
		}
		
		foreach($this->admin->perm->_storage->fields as $key=>$value) {
		
			
			if (in_array($key,array_keys($result[0]))) {
				  if (in_array($key,$fieldsToRender)) {
				  		$form->addElement('text', $key, $key, 
array('value'=>$result[0][$key]));	
				  }
				
				  if (in_array($key,$fieldsToHide)) {
				  		$form->addElement('hidden', $key);	
				  }
			}
		}
		$form->addElement('submit', 'btnSubmit', 'Edit '.$result[0][$key]);
		return $form;
	}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.