Hi , i need Help. I`m new to symfony 1.2 and my problem is how to
merge two forms.
I want to build a form where i can rate a category and/or its
attributes.
my schema looks like this
category:
id: ~
name: { type: varchar(255), required:true }
attribute:
id: ~
name: { type: varchar(255), required: true }
infotext: { type: longvarchar(255), required:false }
category_id: { type: integer, foreignTable: category,
foreignReference: id, required: true}
rating_for_category:
id: ~
rating_id: { type: integer, foreignTable: rating,
foreignReference: id, required: true}
category_id: { type: integer, foreignTable:
category, foreignReference: id, required: true}
avg_point: { type: double , required: false, default: 0 }
_uniques:
rating_for_category_index:[rating_id, category_id]
rating_for_attribute:
id: ~
rating_id: { type: integer, foreignTable: rating,
foreignReference: id, required: true}
attribute_id: { type: integer, foreignTable:
attribute, foreignReference: id, required: true}
points: { type: double , required: false,
default: 0 }
_uniques:
rating_for_attribute_index: [rating_id, attribute_id]
rating:
id: ~
.
user_id: { type: integer, foreignTable: sf_guard-user,
foreignReference: id, required: true}
active: { type: varchar, sqltype:enum, size:
"'0','1'", default: 0, required: true }
created_at: ~
updated_at: ~
_uniques:
rating_index: [user_id]<<< sfguard a.s.o
the avg-point in "rating_for_category" comes from the avg of
attributes points
my "try" is in the lib/forms/myform.php
$inputField = new sfWidgetFormChoice(
array(
'choices' => array
('0','1','2','3','4','5'),
'multiple' => false,
'expanded' =>
false
)
);
$a_categories = CategoryPeer::getAllCategoriesWithAttributes();
foreach($a_categories as $o_category)
{
$this->widgetSchema['category_'.$o_categorie->getId()] =
$inputField;
$this->widgetSchema->setLabel('category_'.$o_categorie-
>getId(), $o_categorie->getName());
foreach($o_categorie->attribute AS $o_attribut) {
$attributsForm = new AttributeForm($o_attribut);
$this->embedForm('attribut_'.$o_attribut->getId(),
$attributsForm);
$this->widgetSchema['attribut_'.$o_attribut->getId()]
= $inputField ;
$this->widgetSchema['attribut_'.$o_attribut->getId()]-
>setLabel($o_attribut->getName());
}
}
after many hours ot testing in the template i tried to access the
fields with
<?php $schema = $form->getFormFieldSchema(); ?>
<?php while ($schema->offsetExists($schema->key())): ?>
<?php if(substr($schema->key(),0,1)=='c'): ?>
<div class="category">
<?php echo $schema->current()->isHidden() ? $schema->current()-
>render() : $schema->current()->renderRow(); ?>
</div>
<?php else: ?>
<div class="attribute" >
<?php echo $schema->current()->isHidden() ? $schema->current()-
>render() : $schema->current()->renderRow(); ?>
</div>
<?php endif;?>
<?php $schema->next(); ?>
<?php endwhile; ?>
because with the std. decorator it wont work
i cant show you results online(there are none) but the nearest what i
found is something like this
http://www.bilder-hochladen.net/files/bl74-1-png.html
in this direction it should go.."rate a catogory or/and its
attributes"
any suggestions? what can be done better? or am i on the wrong path??
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---