Skip to content
This repository was archived by the owner on Jan 31, 2020. It is now read-only.

Setting charset in Doctype::XHTML1_RDFA fails #134

Closed
basz opened this issue Aug 15, 2017 · 6 comments
Closed

Setting charset in Doctype::XHTML1_RDFA fails #134

basz opened this issue Aug 15, 2017 · 6 comments

Comments

@basz
Copy link
Contributor

basz commented Aug 15, 2017

I'm getting an error when I set the charset on a rdfa document. Is that expected? Or an oversight?

        // set doctype
        $this->helperPluginManager->get('doctype')
            ->setDoctype(\Zend\View\Helper\Doctype::XHTML1_RDFA);

$this->helperPluginManager->get('headMeta')
            ->setCharset('utf-8');
Invalid value passed to set; please use setMeta()
./vendor/zendframework/zend-view/src/Helper/HeadMeta.php:442

Further; following the suggestion in the error gives me an error too.

$this->helperPluginManager->get('headMeta')
         ->setMeta('charset', 'utf-8');
Method "setMeta" does not exist
./vendor/zendframework/zend-view/src/Helper/Placeholder/Container/AbstractStandalone.php:83
@samsonasik
Copy link
Contributor

the source of error seems came from

if (! isset($item->content)
&& (! $this->view->plugin('doctype')->isHtml5()
|| (! $this->view->plugin('doctype')->isHtml5() && $item->type !== 'charset'))
) {
return false;
}

@froschdesign
Copy link
Member

froschdesign commented Aug 30, 2017

@basz

Is that expected?

Right, because XHTML has no attribute charset for the meta element.
Use http-equiv:

$this->headMeta()->appendHttpEquiv('Content-Type', 'application/xhtml+xml; charset=utf-8');

@froschdesign
Copy link
Member

froschdesign commented Aug 30, 2017

We should add a check or throw an Exception for this case.

@samsonasik
Copy link
Contributor

@basz @froschdesign I've created PR #137 for it.

@froschdesign froschdesign added this to the 2.9.1 milestone Aug 30, 2017
@basz
Copy link
Contributor Author

basz commented Sep 1, 2017

thanks all!

@froschdesign
Copy link
Member

@basz
Thanks for reporting! 👍

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants