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.

Data Model Questions /

[SOLVED] Save dataObject in frontend


4 Posts   983 Views


Community Member, 58 Posts

7 October 2012 at 3:08am

Edited: 08/10/2012 11:51am

I build portal and i have a problem with dataobject in frontend

Can someone help me?

Generally everything works fine except fuction to save "dosave"

Sorry for my bad English

Obsolete - updated the code below


Community Member, 58 Posts

7 October 2012 at 3:15pm

Edited: 08/10/2012 11:53am

Maybe I write differently.
Code is based on the module forum.

In code module forum after delete unnecessary code i have code - attach file (ForumCode.php):

Based on this code I create this code: attach file (myCode.php)

Has anyone an idea?
Generally, in frontend i have form to edit "obiekt" with right ID but when i click save changes is not save.

Editting adress: www.mysite/edytuj/edit/30
30 - sample ID Object to edit
when I click save changes i have www.mysite/edytuj/EditObiektForm, should be www.mysite/edytuj/thanks and should be save :)

Generally runs most of the exception object save.
I think that i bad write function dosave or getObiekt, something does not work in get by ID - i think

Sorry for my bad English

Attached Files

Community Member, 58 Posts

8 October 2012 at 6:16am

Edited: 08/10/2012 11:54am

I found half of the error:
I limited allow action - now i delete this.
Now when I click save change i have error

Fatal error: Call to a member function getObiektFields() on a non-object in on line 40

Probably function getObiekt() is wrong write

ObiektRole.php (here is function getObiektFields())

class ObiektRole extends DataObjectDecorator {
function extraStatics() {
$fields = array(
'db' => array(
'City' => 'Varchar'
'has_one' => array(
'Avatar' => 'Image'
return $fields;

function getObiektFields() {
$obiektDetailsFields = new CompositeField(
new TextField('City', _t('ForumRole.CITY', 'City')),
new SimpleImageField('Avatar', 'Zdjecie')
$fieldset = new FieldSet(
return $fieldset;


Community Member, 58 Posts

8 October 2012 at 9:46pm

Edited: 09/10/2012 12:01pm

No one has an idea?
I'm so desperate :/


When I change function getObiekt and I give a specific ID
function getObiekt() {
$obj = DataObject::get_by_id("Obiekt", 47);
return $obj;

then all good.

My function is not able to ID

function getObiekt(){
$obiekt = Director::urlParams();
return DataObject::get_by_id("Obiekt",(int)$obiekt['ID']);
return false;

Any idea?

to function EditObiektForm()
need add $fields->push(new ReadonlyField("ID"));

function EditObiektForm() {
$member = $this->getObiekt();

$fields = singleton('Obiekt')->getObiektFields();
$fields->push(new ReadonlyField("ID"));
$form = new Form($this, 'EditObiektForm', $fields,
new FieldSet(new FormAction("dosave", _t('ForumMemberProfile.SAVECHANGES','Save changes')))

return $form;