i have 2 models below
class communication extends \typo3\cms\extbase\domainobject\abstractentity { /** * @var filter */ protected $filter; } class filter extends \typo3\cms\extbase\domainobject\abstractentity { /** * @var \typo3\cms\extbase\persistence\objectstorage<\typo3\cms\extbase\domain\model\frontendusergroup> */ protected $usergroup; }
template below
<f:form class="form-horizontal" name="communication" action="update" object="{communication}"> <div class="form-group"> <label class="col-xs-3 col-md-2 control-label" for="bodytext">{f:translate(key: 'text.usergroup')}</label> <div class="col-xs-9 col-md-10"> <f:for each="{usergroups}" as="group"> <label class="checkbox-inline"> <f:form.checkbox property="filter.usergroup" value="{group.uid}" /> {group.title} </label> </f:for> </div> </div> <div class="form-group"> <div class="col-xs-9 col-md-10 col-xs-offset-3 col-md-offset-2"> <button type="submit" class="btn btn-primary">{f:translate(key: 'button.update')}</button> </div> </div> </f:form>
when try update communication $this->communicationrepository->update($communication)
, creates new filter rather updating own. why this?
this because there no relation filter there. keeping filter need id has. found out works __identity field:
edit: better wrap field if condition in case there no filter set
<f:if condition="{communication.filter.uid}"> <f:form.hidden name="communication[filter][__identity]" value="{communication.filter.uid}" /> </f:if>
not sure, possible works uid property field:
<f:form.hidden property="filter.uid" />
Comments
Post a Comment