PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » HTML » HTML_QuickForm » Bug #3938

css (class) support for element setMaxFileSize()

Details

Request #3938css (class) support for element setMaxFileSize()
Submitted2005-03-24 09:17 UTC
Fromog at creatics dot de
StatusWont fix
PackageHTML_QuickForm
PHP VersionIrrelevant
OSMacOS X
Roadmaps(Not assigned)

Comments

[2005-03-24 09:17 UTC] og at creatics dot de

Description:
------------
Sometimes it is necessary to cling a css class to the hidden input field delivered by $form->setMaxFileSize();

Because of a Bug, Mozilla assigns styles not only to visible input`s, but even to hidden fields.

Therefore it is not possible to avoid redundant styles by declaring the generic 'input {}' and add some additional styles to input selectors (e.g. 'input.iShort{}') after that.

You have to define all single input element to avoid this (wrong) behaviour of Mozilla.

Could be done with some simple lines (below).,.

Reproduce code:
---------------
Quickform.php
line 468

function setMaxFileSize($bytes = 0, $attr = null)
{
if ($bytes > 0) {
$this->_maxFileSize = $bytes;
}
if (!$this->elementExists('MAX_FILE_SIZE')) {
$this->addElement('hidden', 'MAX_FILE_SIZE', $this->_maxFileSize);
} else {
$el =& $this->getElement('MAX_FILE_SIZE');
if (empty($attr)) {
$el->updateAttributes(array('value' => $this->_maxFileSize));
} else {
$el->updateAttributes(array('value' => $this->_maxFileSize, 'class' => $attr));
}
}
} // end func setMaxFileSize

Expected result:
----------------
Controller:
$form->setMaxFileSize($bytes, $attr);

View (Output):
<input name="MAX_FILE_SIZE" type="hidden" value="$bytes" class="$attr" />

[2005-03-24 09:29 UTC] bmansion at mamasam dot com

If this is a bug in Mozilla, it should be fixed in Mozilla.

Anyway, I don't think it is a good idea to style the global input element in your css. IMO, You'd rather use a class for the input you want to style on a per case basis.

As a webdesigner, I am personally strongly against styling inputs (except to fix their width maybe), because they were designed in such a way to make them accessible and they should adapt to user's browser preferences.

Thanks anyway for the info.

[2005-03-24 10:11 UTC] og at creatics dot de

Thanks for reypling.

Anyhow, i dont agree with your method of styling (or not ;)) form elements. In General, styling form elements could be useful not only to 'design' the view, but for usability reasons (various interpretations of paddings/margins and font sizes etc.).

You are right, Browser depending bugs should be fixed within the application, but this seems to turn out wishful thinking as long as i beeing in this business.

I wonder, why class support is provided in QuickForm on all other $form->elements (except this particular hidden field), if styling elements is not recommended...

Anyway. Thanks for QuickForm as it is. Really useful !