zendframework / zend-view

View component from Zend Framework
BSD 3-Clause "New" or "Revised" License
49 stars 61 forks source link

Setting charset in Doctype::XHTML1_RDFA fails #134

Closed basz closed 7 years ago

basz commented 7 years ago

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 commented 7 years ago

the source of error seems came from https://github.com/zendframework/zend-view/blob/4d9954c05a3981ca711bd55932dc1d2b55580392/src/Helper/HeadMeta.php#L337-L342

froschdesign commented 7 years ago

@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 commented 7 years ago

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

samsonasik commented 7 years ago

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

basz commented 7 years ago

thanks all!

froschdesign commented 7 years ago

@basz Thanks for reporting! 👍