I need a small clarification for adding element in a Form class, generally becasue I still trying to wrap my head around OOP...
We can declare element in form in two ways :
class SomeForm extends Form {
public function initialize($entity = null, $options = null)
{
#First Way
$name = new Text('name', [
'placeholder' => 'Name',
'otherProperty' => 'Property'
]);
$name->setLabel('Name');
$this->add($name);
#Second Way
$this->add(new Text('name', [
'placeholder' => 'Name',
'otherProperty' => 'Property'
]));
} }
I understand that first one is more flexible while second one is shorter. My question is that can we add HTML Label to element in "second way" ?