This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use Stack Overflow.

partial field and filter with admin generator

Discussion specific to symfony 1.1.x stable

partial field and filter with admin generator

by pajak » Mon Nov 17, 2008 11:56 pm


i try to make partial filter on partial field with admin generator.
partial field named godzyear is made as 4 digit year part (eg. 2008) from table field which contains date. it is located in ...\modules\godziny\templates\_godzyear.php

Code: Select all
<?php $datetime = new DateTime($godziny->getData() . ' 00:00:01');
echo DATE_FORMAT( $datetime, "Y" ;); ?>

partial filter looks:
Code: Select all
<?php echo select_tag('filters[godzyear]', options_for_select(array(
  '' => '',
  '2008' => '2008',
  '2009' => '2009',
  '2010' => '2010',
  '2011' => '2011',
), isset($filters['godzyear']) ? $filters['godzyear'] : '')) ?>

it is located in ...\modules\godziny\templates\_godzyear_filter.php

here is generator.yml
Code: Select all
     godzyear:        { name: Rok }
     godzmonth:       { name: MiesiÄ…c }
     ilosc_godzin:    { name: Godziny }
     ilosc_godzin_ot: { name: W tym nadgodzin }
     title:           Przepracowane godziny
     display:         [ pracownik_id, _godzyear, godzmonth, data, dzien_id, ilosc_godzin, ilosc_godzin_ot]
     filters:         [ _godzyear_filter, godzmonth ]

in action i see aditional column called Rok with proper values and there is a drop-down filter with proper values but this two things does not works together.

i saw in generated code that filter try to use field GODZYEAR_FILTER so it's the reason of not filtering. when i had getGodzYear() in module generated code was trying to get GodzinyPeer::GODZYEAR field which doesn't exist in database :(~ :-(~ :sad:

is it possible to have such combination of field and filter? if yes how to make it works?
best rgds
Junior Member
Posts: 3
Joined: Mon Nov 17, 2008 11:25 pm

Re: partial field and filter with admin generator

by rodrigobb » Thu Sep 16, 2010 7:57 pm

I know this is an old post, but maybe my answer still helps someone.

You need to use filters[godzyear_filter] instead of filters[godzyear] in templates\_godzyear_filter.php
And define in GodzinyPeer the constant
Posts: 39
Joined: Fri Oct 03, 2008 2:41 pm