Ability to override form-level attributes

thread: 4 messages  |  last: about 3 years ago  |  started: wednesday, february 6, 2008, 10:49 pm pst


#1  |  alex94040 (Seattle, WA) United States of America Qcodo Core Contributor
Wednesday, February 6, 2008, 10:49 PM PST

Sometimes, there's a need to override form-level attributes - for example, the only way to disable Firefox's “autocomplete” on textboxes (necessary for credit card numbers, for example) is to set the property on the form tag:

<form autocomplete=“off”>

(see http://developer.mozilla.org/en/docs/How_to_Turn_Off_Form_Autocompletion for details if you want them)

Unfortunately, today, I could not find an easy way to override form-level attributes in QCodo. For Controls, there's a wonderful method SetCustomAttribute; there's nothing like that for forms.

However, QForms do have something that can be used for this purpose - $strFormAttributeArray property of in QFormBase.class.php. If I could do

class MyForm extends QForm {
  protected $strFormAttributeArray = array(“autocomplete”=>”off”);
}

then everything would work just fine.. The problem is, I can't. The value of $strFormAttributeArray gets overwritten by an empty array in QFormBase's RenderBegin() method, with the following line:

$this->strFormAttributeArray = array();

A tiny change would make my scenario possible - replacing the line above with:

if (!isset($this->strFormAttributeArray)) {
  $this->strFormAttributeArray = array();
}

Mike, can you please make that change in the core? Or, if you have more time, can you add a SetCustomAttribute method to the QForms, just like we have it for QControls?

#2  |  stromee (Minneapolis, MN) United States of America
Monday, November 3, 2008, 10:11 PM PST

Has anyone figured this out?  I need to be able to set “autocomplete=off” for a QTextBox that accepts credit card numbers.  Any help is appreciated.

Thanks,
Chris

#3  |  alex94040 (Seattle, WA) United States of America Qcodo Core Contributor
Tuesday, November 4, 2008, 10:04 AM PST

Your best bet is to change the QFormBase's RenderBegin() method as I described above.

#4  |  alex94040 (Seattle, WA) United States of America Qcodo Core Contributor
Tuesday, November 11, 2008, 11:10 AM PST

We are tracking the work item to get this integrated into the core distribution in this QCubed ticket: <http://trac.qcu.be/projects/qcubed/ticket/7>



Copyright © 2005 - 2012, Quasidea Development, LLC
This open-source framework for PHP is released under the terms of The MIT License.