Sunday, August 9, 2009

access buttons on a p4a field with type file

ok. its official. this thing is driving me crazy now. how do i access the buttons on a p4a field with type file???? i have been trying to figure it out and alas no success. the forums tell me one thing, i try it and nothing. I need to know how!

God please give me an answer like you always do?

thanks

time period: one day

4 comments:

Andrea said...

$this->fields->myfile->setType('file');
$this->fields->myfile->buttons->button_file_preview->setVisible(false);

ag

Jerome Bailey said...

thanks andrea. i think i have that though. heres my code:

$displayImage_1 = $this->build('p4a_field', 'displayImage_1')
->setType('file')
//->disable()
//->setLabel('Image 1')
//->setValue($_image_1)
//->addAction('onClick')
//->implement("onClick", $this->displayImage_1->buttons->button_file_delete, "testfunction")
;

//$this->intercept($displayImage_1->buttons->button_file_delete, "onClick","testfunction"); //tested from forums
//$this->displayImage_1->addAction('onClick');
//$this->intercept($this->displayImage_1->_objects[2], "afterClick","testfunction"); //tested from forums

//$parentId = $displayImage_1->getParentId();

//$displayImage_1->implement("onClick", $parentId->buttons->button_file_delete, "testfunction");
//$this->intercept( $displayImage_1->buttons->button_file_delete, "onClick", "testfunction" );
/*$this->displayImage_1->buttons->button_file_delete->addAction( "onClick" );
$this->intercept( $this->displayImage_1->buttons->button_file_delete, "onClick", "check" );*/

hopefully you can follow it. as you can see i have tried several things. do you see anything wrong?

Andrea said...

which error do you have?

Jerome Bailey said...

when i use the intercept function i get "Fatal error: Call to a member function implement() on a non-object in /var/www/steve/p4a/p4a/p4a_object.php on line 214"

and when i use the implement function i get "undefined property $button_file_delete on line 598"

line 598 is "->implement("onClick", $this->displayImage_1->buttons->button_file_delete, "testfunction")"

i am just not able to access any of the buttons. when i print the buttons property for the field i created, the array is empty.