Jump to:

23376 Posts in 18214 Topics by 2867 members

General Questions

SilverStripe Forums » General Questions » PopUp form that not popup

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

Page: 1
Go to End
Author Topic: 1126 Views
  • biapar
    Avatar
    Forum Moderator
    435 Posts

    PopUp form that not popup Link to this post

    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?

  • Pigeon
    Avatar
    Community Member
    243 Posts

    Re: PopUp form that not popup Link to this post

    ...
    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.

  • biapar
    Avatar
    Forum Moderator
    435 Posts

    Re: PopUp form that not popup Link to this post

    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?

  • Pigeon
    Avatar
    Community Member
    243 Posts

    Re: PopUp form that not popup Link to this post

    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
    );

    1126 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.