DomingoSL
DomingoSL

Reputation: 15484

Adding a label to a symfony 2 form field

I'm trying to modify a piece of code that generates an input field using the Symfony 2 framework. The thing he creates the field with a default label equals to the name id of the field, in this case; "amount".

<?php 
//++++++++++ descrizione
echo $view['form'] -> row($form["amount"], array(
    //widget
    "widgetArgs" => array(
        "attr" => array(
            'class' => 'input-small tooltipRight', 
            'id' => "gift_amount"
            ),
            "tooltip"=>"gift.tooltip.amount",
            "translation_domain" =>"brand"


         ),
   "labelArgs" => array(
        "label_attr" => array(
            'class' => 'control-label', 
        )) ,"rowType"=>2
      )
  );
?>  

How can i edit this to make it show a custom label?

Upvotes: 0

Views: 1103

Answers (1)

cheesemacfly
cheesemacfly

Reputation: 11762

You have to add the label properties:

<?php 
echo $view['form']->row($form["amount"], array(
    'widgetArgs' => array(
        "attr" => array(
            'class' => 'input-small tooltipRight', 
            'id' => "gift_amount"
            ),
            'tooltip'=>'gift.tooltip.amount',
            'translation_domain' =>'brand'
         ),
     'label'  => 'My ammount',
  ));

Upvotes: 2

Related Questions