Answer the question
In order to leave comments, you need to log in
How, when creating a custom type, can a set of elements be adjusted using a query?
There are three entities above, each of which has an admin class for Sonata. I need to create a form for editing companies. Entity The parameter is required for dynamic configuration of the site. The parameter has a type (4 pieces: text, checkbox, radio and select).
I embed Parameters in the Company, and in the admin parameter class I use custom types for each parameter. However, as indicated in the link diagram, I am getting a list of items that is in no way related to the company I am editing. It looks something like this:
Inside CompanyAdmin:
$formMapper
->with('General')
->add('name', 'text', array('label' => 'Name'))
->add('website', null, array('label' => 'Website'))
->add('about', null, array('label' => 'About', 'required' => false))
->end()
->add('params','sonata_type_collection');
if($param->getType() == 0) {
$formMapper->add('elements', 'element_text', array('company_id' => true) );
} elseif($param->getType() == 1) {
$formMapper->add('elements','element_checkbox', $options );
}elseif($param->getType() == 2){
$formMapper->add('elements','element_radio', $options );
}elseif($param->getType() == 3) {
$formMapper->add('elements','element_select' ,$options);
}
Answer the question
In order to leave comments, you need to log in
weblogs.sqlteam.com/davidm/articles/12117.aspx Here is a description and guide of the EAV model. You need to modify the Element into a table with a composite key. Then the connection between the Company and the parameters is simply not needed, since the company will always be associated with the Element through the Parameter. However, you will have to fool around with the layer to manage all this boyda.
http://stackoverflow.com/
If you greatly simplify and apply to your entities, then
Company manyToMany Element
Company manyToMany Parameter
Element manyToMany Parameter
Parameter manyToOne ParameterType (checkboxes, etc)
"Drawing" a form by type is not difficult, since Parameter is essentially refers many-to-many to Element and Company.
(Pictured)
ProductOptionValue is independent of Option. Option will be generic to Product, and ProductOptionValue will be specific to Product. They have a common Property.
For example.
ProductOptionValue (red, blue, green)
Option (free shipping for red)
All Products with the selected red color and with the corresponding option will be with free shipping, the rest (without the option, will be just with the red color), and the options for the ProductOptionValue are listed here in the Offer (for a single red product, you can set several prices)
What As for the sonata, there should be no problems, except for preUpdate (prePersist), where it will be necessary to work with the reverse side.
In sonata, you can "bind" third-party forms (In the documentation, it is still under the TODO stamp, but it works).
You can beautifully arrange this bunch of entities through tabs (configureSideMenu it seems).
The first thing that caught my eye was that there is no Another in the Element table! )
Where is this from?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question