[fw-general] How to return XML in an Zend Framework Application

2009-10-09 Thread Jayawi

Hi all,

I'm having problems returning XML in my ZF Application.
Below is the code I have:

?php
class ProjectsController extends Gid_Controller_Action
{
 public function xmlAction ()
 {
  $content = ?xml version='1.0'foobar/foo;
  header('Content-Type: text/xml');
  echo $content;
 }
}
?

I've also tried the following:

?php
class ProjectsController extends Gid_Controller_Action
{
 public function xmlAction ()
 {
  $content = ?xml version='1.0'foobar/foo;
  $this-getResponse()-clearHeaders();
  $this-getResponse()-setheader('Content-Type', 'text/xml');
  $this-getResponse()-setBody($content);
  $this-getResponse()-sendResponse();
 }
}
?

Could someone point me in the right direction as to how I go about achieving
this?
Thank you very much.
-- 
View this message in context: 
http://www.nabble.com/How-to-return-XML-in-an-Zend-Framework-Application-tp25818727p25818727.html
Sent from the Zend Framework mailing list archive at Nabble.com.



[fw-general] Zend_Form File Element / Decorator - Extremely Confuzzled

2009-09-09 Thread Jayawi

Hi there~

I'm relatively new to ZF but have enjoyed using it so far. The main issue
I've had with ZF is with it's Form and Decorator aspects. After going
through God knows how many articles/blogs/posts and what not, I thought I
finally had a grasp of it. Things were working okay.

I created a standard set of decorators (for Elements, Buttons and Forms)
based on an example I saw. Recently however, I realised that I needed to add
in some File Input fields into one of the forms. None of the above
decorators worked with it. At which point, I decided to use ViewScripts on
all the forms since it provides greater room to stylise/organise the form.

The code I'm currently using, looks something like the following:

site/application/forms/RegisterForm.php
class ProjectStartContactPersonForm extends Gid_Form
{
public function init ()
{
$this-setAction('')
-setMethod('post')
-setAttrib('id','formStartProject')
-setAttrib('enctype', 'multipart/form-data');

$this-addElement('text', 'textName', array('label' = 'Given 
Name'));
$oName = $this-getElement('textName')
-setRequired(true)

-setDecorators(array('ViewHelper', 'Errors'));

$this-addElement('file', 'filePhotograph');
$oPhotograph = $this-getElement('filePhotograph')
-setRequired(true);

$this-addElement('submit', 'submitRegister', array('label' = 
'Done'));
$oContactPersonSubmit = $this-getElement('submitRegister');
$oContactPersonSubmit-setDecorators(array('ViewHelper', 
'Errors'));

$this-setDecorators(array(array('ViewScript', 
array('viewScript' =
'forms/RegisterForm.phtml';
}
}

site/application/views/scripts/forms/RegisterForm.phtml
div id='iDivRegister'
form action='' method='post'
table
tr
tdlabel for='textName'Name:/label/td
td?php echo $this-element-textName; ?/td
/tr
tr
tdlabel 
for='filePhotograph'Photo:/label/td
td?php echo $this-element-filePhotograph; 
?/td
/tr
tr
td/td
td?php echo $this-element-submitRegister; 
?/td
/tr
/table
/form
/div

From RegisterForm.php I had to change $this-addElement('file',
'filePhotograph', array('label' = 'Photo')); to get it to work. prior to
that, the File Input element was being displayed twice.
Additionally, if -setDecorators(array('ViewHelper', 'Errors')) was attached
to the File Input object, it would throw the error Warning: No file
decorator found... unable to render file element in
C:\xampp\xampp\php\PEAR\Zend\Form\Element.php on line 1929.
I honestly can't understand what the issue is or how I'm supposed to resolve
it. All the searching and reading I did lead me to more questions and no
solution. Some of them dealt with the lack of a File Input Class in ZF
(which I believe was a somewhat early release), while others used custom
classes for things which didn't really clarify anything for me.

Currently, the File Input Element is rendered as follows:
tr
tdlabel for='filePhotograph'Photo:/label/td
td
dt id=filePhotograph-labelnbsp;/dt
ddinput type=file name=filePhotograph 
id=filePhotograph/dd
/td
/tr

I would like to get it outside of those dt/dd tags (which suggest the
default ZF Decorators are being applied).
ZF Documentation I find stragely lacking in the various
methods/variables/parameters to use. If anyone knows of a better reference,
it's sure to help a great deal.

I would greatly appreciate any help anyone can provde me on this.
Thanks~
-- 
View this message in context: 
http://www.nabble.com/Zend_Form-File-Element---Decorator---Extremely-Confuzzled-tp25365664p25365664.html
Sent from the Zend Framework mailing list archive at Nabble.com.



Re: [fw-general] Zend_Form File Element / Decorator - Extremely Confuzzled

2009-09-09 Thread Jayawi

Thanks heaps Daniel and Thomas.

I had actually visited that particular FAQ page before, but I thought it a
dead-end or login-required page when in fact I now realise that it was due
to the horrible internet connection that I have here that the FAQ questions
failed to render as a link.

In any case, the FAQ cleared up the confusion I had on the file element. At
the moment, going through the slides to see what else I can learn.

Thanks again! :)
-- 
View this message in context: 
http://www.nabble.com/Zend_Form-File-Element---Decorator---Extremely-Confuzzled-tp25365664p25377044.html
Sent from the Zend Framework mailing list archive at Nabble.com.