Re: HTML_QuickForm: setType not changing get_class_methods
| From: | Justin Patrin | Date: | Thu, 09 Dec 2004 03:14:10 +0000 |
| Subject: | Re: HTML_QuickForm: setType not changing get_class_methods | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-16129@lists.php.net to get a copy of this message | ||
On Wed, 08 Dec 2004 18:58:19 -0600, Sarah Gray <sarah@fabled.net> wrote:
> Hello,
>
> I am using DB_DataObject_Formbuilder (0.9.0 beta).
> I have a field in a table that I change to a file type so the user can
> upload an image. Like so:
>
> $file =& $form->getElement('presenting_image');
> $file->setType('file');
>
> This shows up & works correctly in my form (ie, an image field with
> browse button appears).
>
> Problem is, when the form is processed and I go to process and upload
> the image, like so...
>
> if( $form->validate()){
> $form->process('process', true);
> ...
> }
>
> The process function I am calling is this;
>
> function process( $values ){
> global $file;
> if ($file->isUploadedFile()) {
> $file->moveUploadedFile($values['path']);
> }
> }
>
> I get the following error message:
> Fatal error: Call to undefined function: isuploadedfile() in
> /usr/local/psa/home/vhosts/morchand.com/httpdocs/admin/programs/create.new.spcase/index.php
> on line 22
>
> Looked like it didn't have the proper method to the object so I printed
> out some debug info( all below). The upshot is, even though it prints
> out 'file' when asked for it's type, it seems to have the methods of a
> text input, not a file input.
>
> Does changing an element by using setType() not work in the way I am
> expecting it to work?
No, it doesn't work that way. setType() is just a setter that *should*
be protected. i.e. only classes which extend the input class should be
using it.
If you want your element to eb of a type different than what FB makes
it, use the preGenerateForm method and set the element in
fb_preDefElements. *or* you can remove and re-create the elemnt in
postGenerateForm, but the preGenerateForm one is the one I use.
> Feel free to correct my thinking or methodology. I am trying to access
> the method for HTML_QuickForm_file, isUploadedFile(), which I thought
> would be accessible to me if I changed the element type to 'file'.
>
> Thanks,
> Sarah
>
> ****
> DEBUG INFO:
>
> When I
> echo $file->getType();
> it prints out 'file'
>
> When I print_r($file) it prints out:
> html_quickform_text Object
> (
> [_attributes] => Array
> (
> [name] => presenting_image
> [type] => file
> [value] => D:\mydocs\16765023_xl.jpe
> )
>
> [_tabOffset] => 0
> [_tab] =>
> [_lineEnd] =>
>
> [_comment] =>
> [_label] => Presenting Image
> [_type] => file
> [_flagFrozen] =>
> [_persistantFreeze] => 1
> )
>
> a when I
> print_r(get_class_methods($file))
> it gives the list of methods associated with a text input object:
>
> Array
> (
> [0] => html_common
> [1] => apiversion
> [2] => _getlineend
> [3] => _gettab
> [4] => _gettabs
> [5] => _getattrstring
> [6] => _parseattributes
> [7] => _getattrkey
> [8] => _updateattrarray
> [9] => _removeattr
> [10] => getattribute
> [11] => setattributes
> [12] => getattributes
> [13] => updateattributes
> [14] => removeattribute
> [15] => setlineend
> [16] => settaboffset
> [17] => gettaboffset
> [18] => settab
> [19] => setcomment
> [20] => getcomment
> [21] => tohtml
> [22] => display
> [23] => html_quickform_element
> [24] => gettype
> [25] => setname
> [26] => getname
> [27] => setvalue
> [28] => getvalue
> [29] => freeze
> [30] => getfrozenhtml
> [31] => _getpersistantdata
> [32] => isfrozen
> [33] => setpersistantfreeze
> [34] => setlabel
> [35] => getlabel
> [36] => _findvalue
> [37] => onquickformevent
> [38] => accept
> [39] => _generateid
> [40] => exportvalue
> [41] => _preparevalue
> [42] => html_quickform_input
> [43] => settype
> [44] => html_quickform_text
> [45] => setsize
> [46] => setmaxlength
> )
>
--
Justin Patrin