valid html issue

View: New views
9 Messages — Rating Filter:   Alert me  

valid html issue

by Greg Donald-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I'm using

<?php echo $this->doctype( 'XHTML1_STRICT' ); ?>

in my layout.  Then I'm creating a form like this:

$form = new Zend_Form;
$form->setAction( '/user/signup' )->setMethod( 'post' );
$form->addElement( new Zend_Form_Element_Text( 'username' ) );

which creates an input field that's missing the closing slash near the end:

<input type="text" name="username" id="username" value="">

Is there anything else I'm supposed to do to get valid html?


Thanks,


--
Greg Donald
http://destiney.com/

Re: valid html issue

by jasonistaken :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

This was covered a day or two ago:
http://framework.zend.com/issues/browse/ZF-3323

Greg Donald wrote:

> I'm using
>
> <?php echo $this->doctype( 'XHTML1_STRICT' ); ?>
>
> in my layout.  Then I'm creating a form like this:
>
> $form = new Zend_Form;
> $form->setAction( '/user/signup' )->setMethod( 'post' );
> $form->addElement( new Zend_Form_Element_Text( 'username' ) );
>
> which creates an input field that's missing the closing slash near the end:
>
> <input type="text" name="username" id="username" value="">
>
> Is there anything else I'm supposed to do to get valid html?
>
>
> Thanks,
>
>
>  


Re: valid html issue

by weierophinney :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

-- Greg Donald <gdonald@...> wrote
(on Wednesday, 28 May 2008, 10:13 PM -0500):

> I'm using
>
> <?php echo $this->doctype( 'XHTML1_STRICT' ); ?>
>
> in my layout.  Then I'm creating a form like this:
>
> $form = new Zend_Form;
> $form->setAction( '/user/signup' )->setMethod( 'post' );
> $form->addElement( new Zend_Form_Element_Text( 'username' ) );
>
> which creates an input field that's missing the closing slash near the end:
>
> <input type="text" name="username" id="username" value="">
>
> Is there anything else I'm supposed to do to get valid html?

This has been covered a number of times. You need to set the doctype in
your bootstrap or an early-running plugin so that it can be used in your
action view scripts; when you set it in the layout, it's too late, as
these have already been rendered.

There's an issue already posted to update the documentation to note
this.

--
Matthew Weier O'Phinney
Software Architect       | matthew@...
Zend - The PHP Company   | http://www.zend.com/

Re: valid html issue

by Greg Donald-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 5/29/08, Matthew Weier O'Phinney <matthew@...> wrote:
> You need to set the doctype in
>  your bootstrap or an early-running plugin so that it can be used in your
>  action view scripts; when you set it in the layout, it's too late, as
>  these have already been rendered.

That would seem problematic since it would force the application to
only use a single doctype, using XHTML1_STRICT when I really need to
use XHTML1_FRAMESET for example.

I guess I'll just use regular html tags and skip this particular helper.


--
Greg Donald
http://destiney.com/

Re: valid html issue

by weierophinney :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

-- Greg Donald <gdonald@...> wrote
(on Thursday, 29 May 2008, 09:51 AM -0500):
> On 5/29/08, Matthew Weier O'Phinney <matthew@...> wrote:
> > You need to set the doctype in
> >  your bootstrap or an early-running plugin so that it can be used in your
> >  action view scripts; when you set it in the layout, it's too late, as
> >  these have already been rendered.
>
> That would seem problematic since it would force the application to
> only use a single doctype, using XHTML1_STRICT when I really need to
> use XHTML1_FRAMESET for example.

The helpers that are doctype aware are only considering whether or not
they are HTML or XHTML -- strictness is not considered.

Additionally, you can always switch doctype temporarily within your
application view scripts if they need to emit differently than the rest
of the application

--
Matthew Weier O'Phinney
Software Architect       | matthew@...
Zend - The PHP Company   | http://www.zend.com/

Re: valid html issue

by Greg Donald-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 5/29/08, Matthew Weier O'Phinney <matthew@...> wrote:
> The helpers that are doctype aware are only considering whether or not
>  they are HTML or XHTML -- strictness is not considered.
>
>  Additionally, you can always switch doctype temporarily within your
>  application view scripts if they need to emit differently than the rest
>  of the application

Is there a way to do it in the bootstrap?

Something like this pseudo code?

if controller name == 'admin' && action name == 'index'
  // set frameset doctype
else
  // set regular doctype

I guess I could use $_SERVER['REQUEST_URI'] if nothing else.


--
Greg Donald
http://destiney.com/

Re: valid html issue

by weierophinney :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

-- Greg Donald <gdonald@...> wrote
(on Thursday, 29 May 2008, 12:56 PM -0500):

> On 5/29/08, Matthew Weier O'Phinney <matthew@...> wrote:
> > The helpers that are doctype aware are only considering whether or not
> >  they are HTML or XHTML -- strictness is not considered.
> >
> >  Additionally, you can always switch doctype temporarily within your
> >  application view scripts if they need to emit differently than the rest
> >  of the application
>
> Is there a way to do it in the bootstrap?
>
> Something like this pseudo code?
>
> if controller name == 'admin' && action name == 'index'
>   // set frameset doctype
> else
>   // set regular doctype

I'd do this in a preDispatch() plugin:

    class My_Plugin_Doctype extends Zend_Controller_Plugin_Abstract
    {
        public function preDispatch(Zend_Controller_Request_Abstract $request)
        {
            $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');
            $viewRenderer->initView();
            $view = $viewRenderer->view;

            if (('admin' == $request->getControllerName())
                && ('index' == $request->getActionName()))
            {
                // set frameset doctype
                $view->doctype('XHTML1_FRAMESET');
            } else {
                // set regular doctype
                $view->doctype('XHTML1_STRICT');
            }
        }
    }

Then, register this in your bootstrap:

    $front->registerPlugin(new My_Plugin_Doctype);

--
Matthew Weier O'Phinney
Software Architect       | matthew@...
Zend - The PHP Company   | http://www.zend.com/

Re: valid html issue

by retoreto :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi everyone,

I just tried the solution for setting the Doctype in the Bootstrap and
then printing it in View-scripts as stated in changeset 9531:
 http://framework.zend.com/code/changelog/Zend_Framework?cs=9531

On line 58 it says how to print the doctype in your layout-script:
 <?php echo $this->doctype()->getDoctype() ?>

I think this should rather read:
 <?php echo $this->doctype() ?>
So that it outputs the whole "<!DOCTYPE..."-stuff and not just the
doctype's name-constant.


As always I'm extremely unsure where to post that (reopen the ticket?
open new ticket? email someone) - so I'm posting to the list. sorry :)

Sincerely,
 Reto Kaiser



On Thu, May 29, 2008 at 5:51 AM, Jason Webster <jason@...> wrote:
> This was covered a day or two ago:
> http://framework.zend.com/issues/browse/ZF-3323

Re: valid html issue

by Joó Ádám :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Whoops, sorry for that. As I see, it is already fixed.


Regards,
Ádám

On Fri, May 30, 2008 at 2:59 PM, reto <retoonline@...> wrote:

> Hi everyone,
>
> I just tried the solution for setting the Doctype in the Bootstrap and
> then printing it in View-scripts as stated in changeset 9531:
>  http://framework.zend.com/code/changelog/Zend_Framework?cs=9531
>
> On line 58 it says how to print the doctype in your layout-script:
>  <?php echo $this->doctype()->getDoctype() ?>
>
> I think this should rather read:
>  <?php echo $this->doctype() ?>
> So that it outputs the whole "<!DOCTYPE..."-stuff and not just the
> doctype's name-constant.
>
>
> As always I'm extremely unsure where to post that (reopen the ticket?
> open new ticket? email someone) - so I'm posting to the list. sorry :)
>
> Sincerely,
>  Reto Kaiser
>
>
>
> On Thu, May 29, 2008 at 5:51 AM, Jason Webster <jason@...> wrote:
>> This was covered a day or two ago:
>> http://framework.zend.com/issues/browse/ZF-3323
>