[Solar-talk] Form submission help
Rodrigo Moraes
rodrigo.moraes at gmail.com
Sat Jul 21 17:52:04 CDT 2007
Hi, Raymond.
Welcome to Solar. :)
On 7/21/07, Raymond Kolbe
> However, in order to preserve the MVC aspect of things, wouldn't it be
> best to put the form itself in the view (let's say,
> changepassword.php), and put the 'nuts and bolts' of the code in the
> model (this case being Vendor_App_ChangePassword)?
It is indeed a good idea, and that's how we generally do. Forms can be
loaded from models as you'll see later, and also can be set in a
controller, or even directly in a view template. When using models, we
commonly load forms from them, set the form in a controller property
and them it is available in a view.
The example you mentioned simplifies things a bit for didactic
purposes; we don't use forms in a single file which instantiate a view
object etc. But it serves well to demonstrate how Solar_Form works;
although it seems to not have a 'form_example.view.php' template
example. I guess this is what you miss to get the example working?
Try this for 'form_example.view.php':
<?php
echo $this->form()->auto($this->form)->fetch();
?>
Here, $this->form is the Solar_Form you have assigned to the view in
the example from the manual. $this->form() is the form view helper,
automatically loaded if you start the view and set the helper path to
Solar/View/Helper, like this:
$view = Solar::factory('Solar_View', array('helper_class' =>
'Solar_View_Helper'));
(the second parameter passes the helper path configuration to Solar_View)
Inside a view, you can print isolated form elements using view helpers
(there is one for every kind of form element, check
Solar/View/Helper), or you can use the form() view helper (like above)
to build the HTML for an entire form.
Was this helpful? I hope I understood your question, let me know if not. :)
Hey, if you are interested, join our irc channel #solarphp at
freenode.org to solve quick doubts. There are not many people there
but if you're lucky somebody will not be away and can offer some help.
:)
-- rodrigo
More information about the Solar-talk
mailing list