Generally, you would instantiate the form in the controller, and then pass it
to the view script:
Controller.php
myAction()
{
  $form  = new form();
  $this->view->form = $forml
}

I personally would have the dialog open a URL directly, rather than pass it
content to render, but there's probably not much in it.

After that, if I've understood you correctly, you need to submit the form
via an XHR post; then display the results (errors or success) in the dialog
using Javascript.  You would submit the form to a controller action.

I'm not familiar with jQuery, but there should be plenty of sample code
online to do this - it's a common use case.

If this isn't what you mean, post or link to some code

Yours,
Mark




Escape-Artist wrote:
> 
> Thanks.
> Well what I have is a Zend_Form class, so the code for the form is not in
> the header.
> In the header I instanciate the form. But the code for the validation will
> be in the header ( if I stick to this design ).
> I like your idea of putting it all in a controller.
> But will that work in my case?
> The header.phtml opens a jquery dialog, with the instance of my Zend_Form
> inside.
> I don't know if it's the right structure or not.
> Also, I'd like to be able to validate the form without closing this jquery
> dialog ( so Ajax obviously ) but I'm not quite sure how to do that exactly
> in this case, since the form is in a dialog in a layout, not in a
> controller-action...
> 
> 
> 
> lightflowmark wrote:
>> 
>> Hi - not sure I understand exactly what you're doing, but here are some
>> ideas that may help:
>> 
>> 1) have the dialog open a URL (registerController/registerForm/) rather
>> than put the form code into header.phtml.
>> 
>> 2) pull the content of registerController/registerForm/ using Xhr and
>> then writing it to your dialog, if your dialog widget won't take URLs
>> natively.
>> 
>> 3) use a view helper in header.phtml -
>> $this->view->getRegisterFormForDialog();
>> The view helper would then instantiate the form object, initialise &
>> display it.
>> 
>> 
>> Not sure if any of that illuminates!
>> 
>> M
>> 
>> 
>> 
>> Escape-Artist wrote:
>>> 
>>> Hello everyone, this is my first post here. 
>>> I just started my first project with the Zend Framework ( 1.8 ), so I'm
>>> still trying to wrap my head around all the concepts. 
>>> Ok so I set up the basic structure of my site, with two modules: the
>>> default one ( called front ) and another one called admin.
>>> In my front module I only have two controllers so far: index and error.
>>> I created a layout.phtml that loads the main content, and I've also
>>> added some more layout files: headsetup.phtml ( that sets up the head
>>> part of the html file ), header.phtml and footer.phtml.
>>> Now here's my problem/question:
>>> On my site header ( that stays the same throughout the whole site ) I
>>> have a register button, that when clicked on opens a dialog with the
>>> registration form.
>>> So I'm sure there are a lot of different ways to go for here, but what I
>>> did is create a class that extends Zend_Form. In my header.phtml I added
>>> some code to create a jQuery dialog, that opens when the register button
>>> is clicked ( with an overlay in the background ), and this dialog has an
>>> instance of the Zend_Form.
>>> So far it all works fine. But my concern is with the structure. The
>>> whole point of the framwork is to break everything down to separate
>>> logic, layout and so on.
>>> Here, since this register dialog appears when clicked on a button from
>>> the header, i can't use a controller - action - view system, can I?
>>> Because this register dialog is independant of the rest of the site, it
>>> can be opened from anywhere.
>>> So what should I do? What is the best way to go here? I can put all my
>>> code in header.phtml, which at the moment is working fine ( only got to
>>> the part where the jquery dialog with the register form displays when
>>> button is clicked. I haven't tackled validation and that's where it
>>> might get messy inside the layout class, header.phtml ). But obviously
>>> it'd  be better to break this code down like the controller-action-view
>>> system.
>>> Thanks in advance!
>>> 
>> 
>> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Registration-Form-outside-controllers-tp24175850p24217121.html
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to