[TYPO3-dev] fe_adminLib.inc: parseValues.checkArray faulty?
Marc Wöhlken
woehlken at quadracom.de
Mon Jun 14 20:34:30 CEST 2010
Hi!
When trying to setup a enhanced front end user registration form I
stumbled over a problem which might be a mistake in class user_feAdmin:
- added several checkboxes to my registration form
- set parseValues.fieldname = checkArray
HTML-Setup for checkboxes is like this:
<input type="checkbox" name="FE['fe_users']['fieldname'][0]" value="1"
/> Checkbox a
<input type="checkbox" name="FE['fe_users']['fieldname'][1]" value="1"
/> Checkbox b
When using checkArray the correct values from the database (in this case
both checkboxes are checked) are displayed on the registration form and
the following JS is added automatically:
updateForm('fe_users_form','FE[fe_users][fieldname][0]','1');
updateForm('fe_users_form','FE[fe_users][fieldname][1]','1');
This is correct. Leaving away the "checkArray" will simply result all
checkboxes being unchecked.
When submitting the form to the preview view a problem arises:
The preview uses a hidden field to hold the actual values and updates
these fields be JS,too.
updateForm('fe_users_form','FE[fe_users][filedname]','3');
At this point the value is not an array any more, it has been converted
to a bit representation (1^1+2^1) using the method shown below.
--- user_feAdmin::parseValues() ----
case 'checkArray':
if (is_array($this->dataArr[$theField])) {
reset($this->dataArr[$theField]);
$val = 0;
while(list($kk,$vv)=each($this->dataArr[$theField])) {
$kk = t3lib_div::intInRange($kk,0);
if ($kk<=30) {
if ($vv) {
$val|=pow(2,$kk);
}
}
}
$this->dataArr[$theField] = $val;
} else {$this->dataArr[$theField]=0;}
---
This method does the actual value conversion if the incoming argument is
an array and will return 0 otherwise. And that's a problem.
When trying to save this value in the final step the checkArray routine
is called again and will receive an integer value - 3 in our case -
which will be converted to 0.
That value is then saved to database which effectively removes any
selection done on the initial form.
Maybe I did not understand setting up the forms correctly but as far as
I can see I did everything as described in the documentation.
Is this a problem of the way I use class user_feAdmin or simply a
mistake in the code?
Hoping for comments
Regards
Marc
--
...........................................................
Marc Wöhlken TYPO3 certified integrator
Quadracom - Proffe & Wöhlken
Rembertistraße 32 WWW: http://www.quadracom.de
D-28203 Bremen E-Mail: woehlken at quadracom.de
______________ PGP-Key: http://pgp.quadracom.de
More information about the TYPO3-dev
mailing list