[Solar-talk] Question about using forms

Cruz, Darwin Darwin.Cruz at gd-ais.com
Wed Nov 21 10:48:54 CST 2007


i'v tried to implement the manual approach that Paul suggested and can't
get it to work. 

doing:  
		echo $this->form($this->form);  

will show the complete form with both elements.

but when i try: 
		echo
$this->formInput($this->form->elements['user_email']);  


All i get is a blank page when i load it in the browser.  I've checked
my Apache access.log and found the following error.

Any ideas?
Also note that i am using Solar version 1.0.0alpha1.  I just copied the
files and moved then into my Solar-0.28.0 directory.  



127.0.0.1 - - [21/Nov/2007:11:44:17 -0500] "GET
/Solar/PatrolAvailability/formtest HTTP/1.1" 200 61
PHP Fatal error:  Uncaught exception
'Solar_Controller_Page_Exception_DuringFetch'
class::code 'PROJECT_App_PatrolAvailability::ERR_DURING_FETCH' 
with message 'Exception encountered in the fetch() method.' 
information array (
  'exception' => 
  Solar_Class_Stack_Exception_ClassNotFound::__set_state(array(
     '_info' => 
    array (
      'name' => 'FormInput',
      'stack' => 
      array (
        0 => 'PROJECT_App_PatrolAvailability_Helper_',
        1 => 'PROJECT_View_Helper_',
        2 => 'Solar_View_Helper_',
      ),
    ),
     '_class' => 'Solar_Class_Stack',
     'message' => 'ERR_CLASS_NOT_FOUND',
     'string' => '',
     'code' => 'ERR_CLASS_NOT_FOUND',
     'file' => 'C:\\Solar Framework\\Solar-0.28.0\\Solar.php',
     'line' => 363,
     'trace' => 
    array (
      0 => 
      array (
        'file' => 'C:\\Solar Framework\\Solar-0.28.0\\Solar.php',
        'line' => 558,
        'function' => 'factory',
        'class' => 'Solar',
        'type' => '::',
        'args' => 
        array (
          0 => 'Sola in C:\Solar Framework\Solar-0.28.0\Solar.php on
line 363
127.0.0.1 - - [21/Nov/2007:11:44:18 -0500] "GET
/Solar/PatrolAvailability/formtest HTTP/1.1" 200 61


------------------------------------------------------------------------
------------

Not in left field, exactly, but it can be done.  It's just not fully
automated.

Darwin, there are two solutions: a full-manual approach, and a semi-
automatic approach.

The full-manual approach is to use the individual form element helpers,
like so.

     echo $this->formInput($this->invForm->elements['user_email']);

That will output just the <input> tag with the information from the
user_email element.  You get no messages, no labels, none of the cool
stuff -- but you have full control over the placement and the
surrounding XHTML.  You can additionally access the elements[] array to
get label and validation messages, and manually place them any way you
like.

The semi-automatic approach uses the form helper element methods to
intersperse XHTML where you want it, along with groupings, but you're
stuck with the <dl></dl> CSS-based approach then.

     echo $this->form()
               ->xhtml('<div name="foo">')
               ->input(this->invForm->elements['user_email'])
               ->xhtml('</div>')
               ->fetch();

The main benefit of this approach is that you can start using the
built-in fieldset and grouping methods very easily, without having to
mix in raw XHTML, and it keeps all the validation messages and labels in
place.

     echo $this->form()

               ->beginFieldset('Email Information')
               ->input(this->invForm->elements['user_name'])
               ->input(this->invForm->elements['user_email'])

               ->beginGroup('Actions')
               ->submit($this->invForm->elements['save'])
               ->submit($this->invForm->elements['cancel'])
               ->reset($this->invForm->elements['reset'])
               ->endGroup()

               ->endFieldset()
               ->fetch();

While this helps with CSS based forms and (pseudo-) semantic XHTML, it
probably won't do the trick for you if you're required to use tables for
forms.

Perhaps it's time for an additional table-based form helper?  Happy to
take contributions there.

Hope this helps, let me know if it does not.


--

Paul M. Jones  <http://paul-m-jones.com>

Solar: Simple Object Library and Application Repository for PHP5.
<http://solarphp.com>

Join the Solar community wiki!  <http://solarphp.org>

Savant: The simple, elegant, and powerful solution for templates in PHP.
<http://phpsavant.com>


_______________________________________________
Solar-talk mailing list
Solar-talk at lists.solarphp.com
http://mailman-mail3.webfaction.com/listinfo/solar-talk



More information about the Solar-talk mailing list