0

i have a symfony entity called Config

class Config
{
/**
 * @var integer
 *
 * @ORM\Column(name="id", type="integer")
 * @ORM\Id
 * @ORM\GeneratedValue(strategy="AUTO")
 */
private $id;

/**
 * @var string
 *
 * @ORM\Column(name="key_name", type="string", length=255)
 */
private $keyName;

/**
 * @var string
 *
 * @ORM\Column(name="key_value", type="text", nullable=true)
 */
private $keyValue;


/**
 * @var string
 *
 * @ORM\Column(name="key_type", type="string", length=255)
 */
private $keyType;

/**
 * @var string
 *
 * @ORM\Column(name="key_tab", type="string", length=255)
 */
private $keyTab;

controller :

class ConfigController extends Controller
{

/**
 * Lists all Config entities.
 *
 */
public function indexAction()
{
    $em = $this->getDoctrine()->getManager();

    $entities = $em->getRepository('MyBundle:Config')->findAll();

    $configCollection = array('configs'=>$entities);

    $collection = $this->createForm(new ConfigsType, $configCollection);

    return $this->render('MyBundle:Config:index.html.twig', array(
        'edit_form' => $collection->createView(),

    ));
}

view :

{% macro config_row(elem) %}
<div class="form-group">
{{ form_label(elem.keyValue, 'fff', { 'label_attr': { 'class': 'col-md-3 control-label' }}) }}
{# elem.keyName|humanize #}
<div class="col-md-4">
     {{ form_widget(elem.keyValue, {'attr': { 'class': 'form-control input-large' }}) }}
     {{ form_errors(elem.keyValue) }}

</div>
</div>
{% endmacro %}

<form action="{{ path('my_config') }}" method="post" {{ form_enctype(edit_form) }} >
 {% for conf in edit_form.configs %} 
      {{ _self.config_row(conf) }} 
    {% endfor %}
 </div>
 {{ form_rest(edit_form) }}
 </form>

what i need is for each config row i can get properties values in the config_row template to customize html rows structure based on their values

any idea please ?

thank you.

1
  • You question is not clear. Can you please reword it ? Commented Oct 2, 2014 at 14:58

1 Answer 1

1

If I understand you correct you want to retrieve the value of each property of instance of entity Config, right?

If so, properties should be accessible by doing this:

{{ conf.vars.data.id }}
{{ conf.vars.data.keyName }}
{{ conf.vars.data.keyValue }}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.