0

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?

1 Answer 1

2

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',
  ));
Sign up to request clarification or add additional context in comments.

7 Comments

This works nice, Thanks!, but can you please show me how to do the same but using the translation service?
You mean with a call to $this->get('translator')->trans('My ammount') instead of 'My ammount'?
do you think is possible to add some style to the label? because simple by doing 'label' => '<b>My Label</b>' do not work
When you say it doesn't work, what does it render? I know you can add a CSS class with 'attr' => array('class' => 'my_class') if that could do it for you.
It just renders the string with the tags <b>
|

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.