[TYPO3-mvc] editAction doesn't work
typo3 at markus-guenther.de
typo3 at markus-guenther.de
Tue Aug 10 12:53:39 CEST 2010
Hello,
i am a new and bein to program extension with extbase. I am in
industrial training but the most are programming pi base extensions. so
i hope that one of you can tell me why my updateAction dont work.
I want build a extension that offers users the possibility to subscribe
for appointments. A Appointment only have a date an some Timeslots and
the User can subscribe for a Timeslot and enter a name and a date.
But when i want to update a timeslot extbase can not find the object in
the repository. any id is not given so he can not know from wich object
it comes.
Timeslot controller:
/**
* Displays a form to edit an existing timeslot
*
* @param Tx_XXX_Domain_Model_Timeslot $timeslot The timeslot to
display
* @dontvalidate $timeslot
*/
public function editAction(Tx_XXX_Domain_Model_Timeslot $timeslot) {
print_r($timeslot);
$this->view->assign('timeslot', $timeslot);
}
/**
* Updates an existing blog
*
* @param Tx_XXX_Domain_Model_Timeslot $timeslot The timeslot to modify
* @return void
*/
public function updateAction(Tx_XXX_Domain_Model_Timeslot $timeslot) {
print_r($timeslot);
$this->timeslotRepository->update($timeslot);
$this->flashMessageContainer->add('Your timeslot was updated.');
$this->redirect('index', 'Appointment');
}
MODEL for Timeslot:
class Tx_XXX_Domain_Model_Timeslot extends
Tx_Extbase_DomainObject_AbstractValueObject {
/**
* time of a Timeslot
* @var string
* @validate NotEmpty
*/
protected $time;
/**
* name of a attendee at this timeslot
* @var string
*/
protected $name;
/**
* name of a attendee at this timeslot
* @var string
*/
protected $phone;
/**
* Setter for time
*
* @param string $time time of a Timeslot
* @return void
*/
public function setTime($time) {
$this->time = $time;
}
/**
* Getter for time
*
* @return string time of a Timeslot
*/
public function getTime() {
return $this->time;
}
/**
* Setter for name
*
* @param string $name name of a attendee at this timeslot
* @return void
*/
public function setName($name) {
$this->name = $name;
}
/**
* Getter for name
*
* @return string name of a attendee at this timeslot
*/
public function getName() {
return $this->name;
}
/**
* Setter for phone
*
* @param string $phone phone number of a attendee at this timeslot
* @return void
*/
public function setPhone($phone) {
$this->phone = $phone;
}
/**
* Getter for Phone
*
* @return string phone of a attendee at this timeslot
*/
public function getPhone() {
return $this->phone;
}
}
?>
REPOSITORY:
class Tx_XXX_Domain_Repository_TimeslotRepository extends
Tx_Extbase_Persistence_Repository {
}
?>
TEMPLATE:
i use in the index.html from the appointment which is the entity.
<f:link.action controller="Timeslot" action="edit" arguments="{timeslot
: timeslot, appointment : appointment}">edit</f:link.action>
and the edit.html from timeslot contains this
<div class="XXX">
<f:flashMessages id="XXX-flashMessages"/>
<div class="XXX-appointment-edit">
<h2 class="XXX-appointment-header"><f:translate
key='tx_XXX_domain_model_timeslot.edit-head' /> - {timeslot.time}</h2>
<f:form method="post" action="update" name="timeslot"
object="{timeslot}">
<div>
<label for="time"><f:translate
key='tx_XXX_domain_model_timeslot.edit-time' /></label>
<f:form.textbox property="time" />
</div>
<div>
<label for="name"><f:translate
key='tx_XXX_domain_model_timeslot.edit-name' /></label>
<f:form.textbox property="name" />
</div>
<div>
<label for="phone"><f:translate
key='tx_XXX_domain_model_timeslot.edit-phone' /></label>
<f:form.textbox property="phone" />
</div>
<button class="std-button" type="submit" name="submit" value="edit">
<em>
<span><f:translate key='tx_XXX_domain_model_timeslot.edit-save'
/></span>
</em>
</button>
<div class="clear"></div>
</f:form>
</div>
</div>
i hope this informations are enough to see what can be wrong.
The Errormessage is:
#1249479819: The "modified object" is does not have an existing
counterpart in this repository.
Tx_Extbase_Persistence_Exception_UnknownObject thrown in file
/var/www/dev.enetr.de/vhosts/viu/htdocs/typo3conf/trunk/050_core/typo3_src-4.4.0/typo3/sysext/extbase/Classes/Persistence/Repository.php
in line 174.
and my output with print_r print out before pressing the save button
Tx_Enetsubscribe_Domain_Model_Timeslot Object ( [time:protected] =>
14:00 [name:protected] => Günther, Ulrich [phone:protected] => -
[uid:protected] => 3 [_localizedUid:protected] => 3
[_languageUid:protected] => 0 [_isClone:private] => )
and after that
Tx_Enetsubscribe_Domain_Model_Timeslot Object ( [time:protected] =>
14:00 [name:protected] => Günther, Ulrich [phone:protected] => -
[uid:protected] => [_localizedUid:protected] => 3
[_languageUid:protected] => 0 [_isClone:private] => )
so thank for reading und i hope that one of you could help.
bye markus
More information about the TYPO3-project-typo3v4mvc
mailing list