Custom CakePHP bake form elements

Hello,

Please, I need a help with the bake customisation. Probably is something basic, but I was not able to find out this information/explanation.

I am using BAKE to create the basic CRUD and then, I am doing some custom. I would like to know where and how to change (for e.g.) the add.php view (template).

On the sourcefile I have the from with the code:

echo $this->Form->control('fkconid');

If I open this (add.php) page and go to look the generated code, I have:

<div class="input number required">
<label for="fkconid">Fkconid</label>
<input type="number" name="fkconid" required="required" data-validity-message="This field cannot be left empty" oninvalid="this.setCustomValidity(&#039;&#039;); if (!this.value) this.setCustomValidity(this.dataset.validityMessage)" oninput="this.setCustomValidity(&#039;&#039;)" id="fkconid" value="1"/>
</div>

I would like to customise the form code above. Please, could someone help me?
P.S.: I also will need to customise the layout page as I am using the AdminLTE3.

My environment:
CakePHP 4.0.3
PHP 7.2.4
AdminLTE 3

As you didn’t say what you want customised I’ll have a guess.

So say you want the text in the label and the text hint changed, you can do: -

echo $this->Form->control('fkconid', ['label' => __('Your Con ID:'), 'placeholder' => __('Enter ID here')]);

Whatever properties belong to the generated fields can be overwritten with that named array.
And any style changes should be handled with your CSS - don’t go sneaking style tags in here!

Cheers

1 Like

Here are the details of what you can change using the options array described by @Jawfin.

Here is a description of how to change the structure of the final output beyond what that allows.

1 Like