logo
Ask your Symfony questions! Pay money and get answers fast! (more info)

Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

If the asker does not get an answer then they have 10 days to request a refund.

$6
Split up EmbedRelations in form by IDs

Hello,

Note: This has been solved with the help from dustin10 on #symfony. Please see my discourse below for more information.

I'm editing a product and its current properties in a form with embedRelation('ProductProperty'). Everything is good so far. E/R diagram here http://d.pr/1N7R

However, now I want to split up the form and show attribute sets in different AJAX tabs according to its SetID. I still want to have a single 'Save' button, but it is not critical if I need to have multiple. How can I do this?

In my _form.php I'm iterating Sets but I can't seem to get the SetID for the ProductProperty form object. Am I going about this the wrong way?

I'm using symfony 1.4 and Doctrine 1.2.

class ProductForm extends BaseProductForm
{
public function configure()
{
unset($this['created_at'], $this['updated_at'], $this['properties_list'], $this['id'], $this['slug']);

$this->embedRelation('ProductProperties');
}
}


_form.php:

<?php foreach($sets as $set) : ?>
<div id="tabs-<?php echo $set->getId() ?>">
<h3><?php echo $set->getTitle() ?></h3>

<table class="form">
<tfoot></tfoot>
<tbody>
<?php if($set->getId() == 1) : ?>
<tr>
<th><?php echo $form['title']->renderLabel() ?></th>
<td><?php echo $form['title'] ?></td>
<td><?php echo $form['title']->renderError() ?></td>
</tr>
<tr>
<th><?php echo $form['sku']->renderLabel('SKU') ?></th>
<td><?php echo $form['sku'] ?></td>
<td><?php echo $form['sku']->renderError() ?></td>
</tr>
<tr>
<th><?php echo $form['category_id']->renderLabel() ?></th>
<td><?php echo $form['category_id'] ?></td>
<td><?php echo $form['category_id']->renderError() ?></td>
</tr>

<?php foreach($form['ProductProperties'] as $eForm) : ?>
<tr>
<th><?php echo $eForm->renderLabel() ?></th>
<td><?php echo $eForm['value'] ?></td>
<td><?php echo $eForm->renderError() ?></td>
</tr>
<?php endforeach; ?>

<?php endif; ?>
</tbody>
</table>
</div>
<?php endforeach; ?>


Here is my schema.yml:

Product:
tableName: products
actAs:
Timestampable: ~
Sluggable:
unique: true
fields: [title]
canUpdate: true
columns:
id:
type: integer
primary: true
autoincrement: true
category_id:
type: integer
notnull: true
sku:
type: string(50)
notnull: true
title:
type: string(150)
notnull: true
relations:
Category:
foreignType: many
foreignAlias: Products

Property:
tableName: properties
actAs:
Timestampable: ~
Sluggable:
unique: true
fields: [description]
canUpdate: true
columns:
id:
type: integer
primary: true
autoincrement: true
set_id:
type: integer
notnull: true
description:
type: string(100)
notnull: true
relations:
Set:
foreignType: many
foreignAlias: Properties

Set:
tableName: sets
actAs:
Timestampable: ~
columns:
id:
type: integer
primary: true
autoincrement: true
title:
type: string(100)
notnull: true

ProductProperty:
tableName: product_properties
actAs:
Timestampable: ~
columns:
product_id:
type: integer
primary: true
property_id:
type: integer
primary: true
value:
type: text
notnull: true
relations:
Product:
alias: Product
foreignType: many
foreignAlias: ProductProperties
onDelete: cascade
Property:
alias: Property
foreignType: many
foreignAlias: PropertyProperties
onDelete: cascade

attachment image asker uploaded image

runeb | 04/04/11 at 12:45pm Edit

Previous versions of this question: 04/04/11 at 12:50pm | 04/05/11 at 4:23pm

(1) Responses

Note: runeb felt their question was unanswered, so we granted them a refund.

Note: runeb requested a refund. They offered no explanation.

If no one challenges a refund request, then they are automatically granted and proccessed after 48 hours. Admins of this site only review refund requests if someone challenges the request. If you are curious about how we handled previous refund requests, you may read over all refund requests and their challenges.

See a threaded view of answers?

Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

  • avatar
    Last edited:
    04/07/11
    5:13am
    anil gupta says:

    you can do like this

    <?php $eForm = $form['ProductProperties'] ?>
    //initialize $eform at the top //

    now u can render field in any place of the document by using
    <?php echo $eForm['fieldname']->rander() ?>

This question has expired.



runeb had additional discourse to offer.



Current status of this question: Refunded



Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

If the asker does not get an answer then they have 10 days to request a refund.