3093 Posts in 875 Topics by 654 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 442 Views |
-
[SOLVED] Save dataObject in frontend

7 October 2012 at 3:08am Last edited: 8 October 2012 11:51am
Hi,
I build portal and i have a problem with dataobject in frontendCan someone help me?
Generally everything works fine except fuction to save "dosave"
Sorry for my bad English
Obsolete - updated the code below
-
Re: [SOLVED] Save dataObject in frontend

7 October 2012 at 3:15pm Last edited: 8 October 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 thinkSorry for my bad English
-
Re: [SOLVED] Save dataObject in frontend

8 October 2012 at 6:16am Last edited: 8 October 2012 11:54am
Ok,
I found half of the error:
I limited allow action - now i delete this.
Now when I click save change i have errorFatal error: Call to a member function getObiektFields() on a non-object in www.mysite.pl/obiekty/code/EditObiektPage.php on line 40
Probably function getObiekt() is wrong write
ObiektRole.php (here is function getObiektFields())
<?php
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(
$obiektDetailsFields
);
return $fieldset;
}
}
?> -
Re: [SOLVED] Save dataObject in frontend

8 October 2012 at 9:46pm Last edited: 9 October 2012 12:01pm
No one has an idea?
I'm so desperate :/EDIT
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();
if(isset($obiekt['ID']))
return DataObject::get_by_id("Obiekt",(int)$obiekt['ID']);
else
return false;
}Any idea?SOLVED
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')))
);$form->loadDataFrom($member);
return $form;}
| 442 Views | ||
|
Page:
1
|
Go to Top |

