Jump to:

23478 Posts in 18941 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » ImageField in ComplexTableField

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: 807 Views
  • Paco728
    Avatar
    Community Member
    28 Posts

    ImageField in ComplexTableField Link to this post

    please help, I get this message to want to attach a picture from the popup in a complextablefield "Images can be attached once you have saved the record for the first time." and I see no error in the code

    NuevoTorneo.php

    $newsTablefield = new ComplexTableField(
    $this,
    'MiNoticia',
    'Noticias',
    array(
    'titulo_not' => 'Titulo',
    'Cont_not' => 'Contenido',
    'img_not' => 'Imagen',
    ),
    'getCMSFields_forPopup'
    );
    $newsTablefield->setAddTitle( 'noticia' );

    $fields->addFieldToTab( 'Root.Content.Noticias', $newsTablefield );

    ..................................................................................................................................................................................................................

    Noticias.php (dataobject)

    static $db = array(
    'titulo_not' => 'Text',
    'Cont_not' => 'Text'
    );

    static $has_one = array(
    'MiTorneo' => 'NuevoTorneo',
    'img_not' => 'Image'
    );

    function getCMSFields_forPopup() {
    $fields = new FieldSet();
        $fields->push( new TextField( 'titulo_not','Titulo' ) );
    $fields->push( new TextareaField( 'Cont_not','Contenido' ) );
    $fields->push( new ImageField( 'img_not','Imagen' ) );
    return $fields;
    }

    Attached Files
  • zenmonkey
    Avatar
    Community Member
    528 Posts

    Re: ImageField in ComplexTableField Link to this post

    Its not an Error, you just need to save the DataObject then add the Images. Pretty sure its because the DataObject needs an ID before you can create the relation with the image and the ID isn't assigned until write() function. It happens whenever you next relations in DataObjects, though it would be nice if other DataObjets functioned more like the Page where it can cache those relations before the Save then write all of them at once.

  • Paco728
    Avatar
    Community Member
    28 Posts

    Re: ImageField in ComplexTableField Link to this post

    I figured that was why the message also appeared to solve it using imagedateobjectmanager ;). Thanks anyway

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