a.shah
a.shah

Reputation: 25

How to convert below code in CakePHP 3?

<div class="form-group">
      <label for="inputEmail" class="col-lg-2 control-label">Title</label>
      <div class="col-lg-10">
        <input type="text" style="width: 45%;" class="form-control" id="titleId" name="title" placeholder="Title">
      </div>
</div>

I have this type of code in my add.ctp file and I don't know how to convert it into like

<? echo $this->Html->input('title',['class'=>'']);

Upvotes: 0

Views: 41

Answers (1)

bikash.bilz
bikash.bilz

Reputation: 821

You have to use Form helper instead of CakePHP Html helper. Form helper helps you to create form field as well as help to validate the form. But Html helper helps you to create Html like Html for image displaying. Here we go

$this->Form->input('title', [
    'label' => [
        'text' => 'Title', 
        'class' => 'col-lg-2'
    ],
    'style' => [
        'width: 45%;'
    ]
]);

I would like to advise you to go to this link, have a deeper look on the docs :)

Here is the Form helper of CakePHP 3

Here is the Html helper of CakePHP 3

Upvotes: 1

Related Questions