Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

PopUp form that not popup


Reply


4 Posts   1173 Views

Avatar
biapar

Forum Moderator, 435 Posts

7 January 2010 at 3:45am

Hi,

I've created a dataobject for add multiple iamge to an object.

public function getCMSFields_forPopup() {

$fields = new FieldSet();
$fields->push(new TextField('Name', 'Name'));
$fields->push(new ImageField('Image', 'Image'));

return $fields;
}

$my_imagetable = new DataObjectManager(
$this,
'ProductImageAttachments',
'Product_ImageAttachment',
Product_ImageAttachment::$field_names,
Product_ImageAttachment::getCMSFields_forPopup(), // form that pops up for edit
"ProductID = {$this->ID}", // a filter to only display item associated with this page
"Name ASC" // Sort by name
);

why form don't popup, but open a normal page and then I must press "back" to return admin and F5 to update node?

Avatar
Pigeon

Community Member, 243 Posts

7 January 2010 at 12:31pm

...
Product_ImageAttachment::$field_names,
Product_ImageAttachment::getCMSFields_forPopup(),
...

is very wrong.

see: http://doc.silverstripe.org/doku.php?id=tutorial:5-dataobject-relationship-management#project_-_student_relation

You should pass an array of the column name and the field you want to show as the first of those two.
the second should be a string of the name of the function to callback.

Avatar
biapar

Forum Moderator, 435 Posts

8 January 2010 at 12:12am

This Product_ImageAttachment::$field_names is an array:

static $field_names = array('Thumbnail' => 'Image','Name' => 'Name');

and the second Product_ImageAttachment::getCMSFields_forPopup() is

public function getCMSFields_forPopup() {

$fields = new FieldSet();
$fields->push(new TextField('Name', 'Name'));
$fields->push(new ImageField('Image', 'Image'));

return $fields;
}

into class Product_ImageAttachment extends DataObject

The problem is that the form where are input fields is opend not in popup window but in the same admin page...

Why?

Avatar
Pigeon

Community Member, 243 Posts

10 January 2010 at 2:51pm

Edited: 10/01/2010 2:57pm

You are currently passing it an array and a function.

As i said before, it needs to be an array and a string.

I am not sure why it is opening in the same window and not a pop-up; but i have a feeling it is because you are implementing the DataObjectManager object incorrectly and not as i have stated you should.

EDIT:
Here is the code to use:

$my_imagetable = new DataObjectManager(
$this,
'ProductImageAttachments',
'Product_ImageAttachment',
array('Thumbnail' => 'Image', 'Name' => 'Name'),
'getCMSFields_forPopup', // form that pops up for edit
"ProductID = {$this->ID}", // a filter to only display item associated with this page
"Name ASC" // Sort by name
);