我試圖使我的枝條頁面上的數組,但我總是碰到下面的錯誤代碼:的Symfony2 /嫩枝 - 錯誤信息:注意:試圖讓非對象的財產
異常被在ProfileBundle中渲染模板(「注意:嘗試獲取C:\ xampp \ htdocs \ JPP \ app \ cache \ dev \ classes.php行10098中的非對象屬性」):Profile:profile.html在線路228
.twig當我看着profile.html.twig我看到下面的for循環:
`{% for Educations in Education|sortByDate %}
<div id="education{{loop.index0}}">
<tr>
<td class="border">{{ Educations.fromDate|date('d-m-Y') }}</td>
<td> </td>
<td class="border">{{ Educations.toDate|date('d-m-Y') }}</td>
<td> </td>
<td class="border">{{ Educations.company }}</td>
<td> </td>
<td class="border" id="jobsChar{{loop.index0}}">{{ Educations.jobs }}</td>
<td> </td>
<td class="border"><input type="button" title="Show Details" class="showDetails" id="details_show{{loop.index0}}"/><input type="button" title="Edit" class="editJob" id="education_edit{{loop.index0}}" /><form style="display:inline" action="../deleteJob" id="deleteJob"><input type="button" title="Delete Job" class="deleteJob" id="job_delete{{loop.index0}}" /></form></td>
</tr></div>{% endfor %}`
在下面你可以看到應該由TWIG的for循環處理的數組,但是沒有成功...
array(5){[0] => array(9){[「id」 ] => int(80)[「userId」] => int(3)[「company」] => string(24)「SolothurnerSpitälerAG」[「jobArea」] => int(0)[「subJobsArea」] => int(2)[「jobLabel」] => string(8)「Förster」[「fromDate」] => object(DateTime)#437(3){[日期「] =>字符串(19)」2010-01-01 00:00:00「[」timezone_type「] => int(3)[」timezone「] => string(13)」Europe/Berlin「} [ 「toDate」] => object(DateTime)#436(3){[「date」] => string(19)「2011-02-09 00:00:00」[「timezone_type」] => int(3) [「timezone」] => string(13)「Europe/Berlin」}} [1] => array(9){[「id」] => int(87)[「userId」] => int(3) [「company」] => string(6)「TOP IT」[「jobArea」] => int(0)[「subJobsArea」] => int(0)[「jobs」] => int(3)[「 jobLabel「] => string(20)」Dipl。 Pflegefachfrau「[」fromDate「] => object(DateTime)#433(3){[」date「] => string(19)」2008-05-01 00:00:00「[」timezone_type「] => int (3)[「timezone」] => string(13)「Europe/Berlin」} [「toDate」] => object(DateTime)#432(3){[「date」] => string(19) (3)[「timezone」] => string 「id」] => int(103)[「userId」] => int(3)[「company」] => string(10)「Helsana AG」[「jobArea」] => int(0)[「subJobsArea 「] => int(0)[」jobs「] => int(1)[」jobLabel「] => string(11)」Holffäller「[」fromDate「] => object(DateTime)#430(3){ 「」date「] => string(19)」2012-10-01 00:00:00「[」timezone_type「] => int(3)[」timezone「] => string(13)」Europe/Berlin「 } [「toDate」] => object(DateTime)#429(3){[「date」] => string(19)「2013-05-01 00:00:00」[「timezone_type」] => int( 3)[「timezone」] => string(13)「Europe/Berlin」}} [3] => array(9){[「id」] => int(104)[「userId」] => int( 3)[「company」] => string(8)「ALPIQ AG」[「jobArea」] => int(0)[「subJobsArea」] => int(0)[「jobs」] => int(2) [「工作(「Date」)=> string(8)「Förster」[「fromDate」] => object 00「[」timezone_type「] => int(3)[」timezone「] => string(13)」Europe/Berlin「} [」toDate「] => object(DateTime)#426(3){[ 「] => string(19)」2013-05-09 00:00:00「[」timezone_type「] => int(3)[」timezone「] => string(13)」Europe/Berlin「}} 4] => array(9){[「id」] => int(130)[「userId」] => int(3)[「company」] => string(8)「ALPIQ AG」[「jobArea」 ] => int(0)[「subJobsArea」] => int(0)[「jobs」] => int(2)[「jobLabel」] => string(8)「Förster」[「fromDate」] =>對象(DateTime)#424(3){[「date」] => string(19)「2013-05-01 00:00:00」[「timezone_type」] => int(3)[「timezone」] = > string(13)「Europe/Berlin」} [「toDate」] => object(DateTime)#439(3){[「date」] => string(19)「2013-05-09 00:00:00 「[」timezone_type「] => int(3)[」timezone「] => string(13)」Europe/Berlin「}}}
請幫助我嗎?非常感謝你。
Cheers Roger
哪一行究竟是228?你在哪裏轉儲數組?在控制器或模板中? –
錯誤可能在您的sortByDate過濾器中。你能發佈代碼嗎? – Webberig
@Mohammad:{%for Education Education in | sortByDate%}是228行。對不起,我忘了提及行! – user2226918