|
Revision 3782, 0.7 KB
(checked in by wjohnald, 2 years ago)
|
|
refactored categories filter to be saved in the session. Added a wrapper to aPeopleTools for setting and getting user attributes.
|
| Line | |
|---|
| 1 | <?php |
|---|
| 2 | |
|---|
| 3 | class PluginaPeopleCategoryForm extends BaseForm |
|---|
| 4 | { |
|---|
| 5 | public function configure() { |
|---|
| 6 | parent::configure(); |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | $categories = $this->getCategoryQuery()->fetchArray(); |
|---|
| 10 | |
|---|
| 11 | $choices = array(); |
|---|
| 12 | |
|---|
| 13 | foreach($categories as $id => $category) |
|---|
| 14 | { |
|---|
| 15 | $choices[$id] = $category['name']; |
|---|
| 16 | } |
|---|
| 17 | |
|---|
| 18 | $this->widgetSchema['categories'] = new sfWidgetFormChoice(array('multiple' => true, 'choices' => $choices)); |
|---|
| 19 | $this->validatorSchema['categories'] = new sfValidatorChoice(array('choices' => array_keys($choices))); |
|---|
| 20 | |
|---|
| 21 | $this->widgetSchema->setNameFormat('aPeopleCategoryFilter[%s]'); |
|---|
| 22 | } |
|---|
| 23 | |
|---|
| 24 | public function getCategoryQuery() |
|---|
| 25 | { |
|---|
| 26 | return Doctrine_Query::create() |
|---|
| 27 | ->from('aCategory INDEXBY id') |
|---|
| 28 | ->select('name'); |
|---|
| 29 | } |
|---|
| 30 | } |
|---|