We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Clarification for setLabel in FORM this way ..

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" ?