[FLOW3-general] Object argument becomes null
Scott MacDonald
smacdav at gmail.com
Sun Jul 25 22:23:30 CEST 2010
On or about 7/25/2010 3:10 PM, Michael Sauter said:
> On 25.07.10 18:16, Scott MacDonald wrote:
>> I saw an earlier thread that seemed to be similar to this but there were
>> few details and it wasn't resolved.
>>
>> I completed the flow3 1.0.0 alpha 7 tutorial on the web site then
>> downloaded flow3 1.0.0 alpha 10 to work on my own project. In my
>> project, I have a Disc object in the model:
>>
>> <?php
>> declare(ENCODING = 'utf-8');
>> namespace F3\TrackLibrary_PHP\Domain\Model;
>>
>> /**
>> * A disc
>> *
>> * @scope prototype
>> * @entity
>> */
>> class Disc {...
>>
>> In DiscController.php, I have a create action and an edit action:
>>
>> /**
>> * Creates a new disc
>> *
>> * @param \F3\TrackLibrary_PHP\Domain\Model\Disc $disc A fresh Disc
>> object which has not yet been added to the repository
>> * @return void
>> */
>> public function createAction(\F3\TrackLibrary_PHP\Domain\Model\Disc
>> $disc) {
>> $this->discRepository->add($disc);
>> $this->disc = $disc;
>> $this->redirect('edit', \NULL, \NULL, array('disc' => $disc));
>> }
>>
>> /**
>> * Edit a disc
>> *
>> * @param \F3\TrackLibrary_PHP\Domain\Model\Disc $disc
>> * @return string
>> */
>> public function editAction(\F3\TrackLibrary_PHP\Domain\Model\Disc $disc)
>> {...
>>
>> The first two lines in createAction are things I put in there while
>> debugging in order to confirm the issue. The code of editAction doesn't
>> matter because I never get there. The problem is that the $disc argument
>> passed to editAction is NULL. Running a debugger, I found that those
>> first two lines of createAction don't stick: if I get rid of the
>> argument for editAction in order to get it to execute, $this->disc is
>> NULL and $this->discRepository is empty once I enter editAction.
>>
>> Can anyone see what I'm doing wrong? I'm happy to provide more details,
>> if needed.
>>
>> Thanks,
>>
>> Scott
>
> Hi Scott,
>
> how do you call the create action? Are you sure you're not passing
> NULL there already?
>
> ~michael
> _______________________________________________
Hi Michael,
The create action is called as a result of a form being filled out:
<f:form method="post" action="create" object="{disc}" name="disc"
onsubmit="return validateNewForm(this)"
enctype="multipart/form-data">
<f:form.hidden name="numTracks" value="5" property="numTracks"/>
<f:form.hidden name="isNew" value="true" property="isNew" />
<fieldset>
<legend>Artist</legend>
<label for="artist" style="float:left;width:22ex">
Enter name of artist:
</label>
<f:form.textbox property="artist" id="artist" />
</fieldset>
<br />
<fieldset>
<legend>Disc</legend>
<label for="title" style="float:left;width:15ex">
Enter disc title:
</label>
<f:form.textbox id="title" size="25" property="title" />
</fieldset>
<br />
<div style="text-align:center">
<f:form.submit class="button" value="Create Disc />
</div>
</f:form>
In my debugging runs, $disc is not NULL while the create action is
running. (I had that problem for a time, but figured out what I was
doing wrong for that one.) It does, however, say that $disc is of type
F3\TrackLibrary_PHP\Domain\Model\Disc_AOPProxy_Development. Not
surprisingly, saving $disc to $this->disc produces the same type for
$this->disc. In case it helps, $this->disc is declared as follows:
/**
* @var \F3\TrackLibrary_PHP\Domain\Model\Disc
*/
protected $disc;
The actual error message is this:
#1269616784: The value of argument "disc" must be of type
"F3\TrackLibrary_PHP\Domain\Model\Disc", but was of type "NULL".
More information about the FLOW3-general
mailing list