Attributes for label element

Is there a quick way in Forms\Element to set attributes for the label element ? My current workaround is just to use markup in a volt viewfile : <label class="control-label" for="registered_name">Registered Name</label>

I use this now in my form class : $registered_name->setLabel("Registered name");

then the view : {{ form.label('registered_name') }}

gives : <label for="registered_name">Registered Name</label>

So, I would like to add the "class" attribute to this.

I am happy to make a render method as per : http://docs.phalconphp.com/en/latest/reference/forms.html#rendering-forms

What about {{ form.label("registered_name", ["class" : "classname"]) }}?



434

Thank you Dave. I thought there might be a way to do it in the class rather than code it in the view. But that will do.

As an aside, I did read the docs here : http://docs.phalconphp.com/en/latest/api/Phalcon%5Forms%5Element.html public string label ([unknown $attributes])

Got close, but the Volt array notation was wrong {{ form.label, ["class"=>"control-label"] }} ... and then I saw your reply. Cheers.

Hi Greg. There may be a way to do it in the class but I'm not aware of it. This said, the class is a presentation attribute and to me, it seems more appropriate in the view than in the controller/form class. I may be wrong - bear in mind I'm a beginner too ;-).