Abdus Sattar Bhuiyan
Abdus Sattar Bhuiyan

Reputation: 3074

How to create my own name attribute in CakePHP Form?

I am using CakePHP 3. I would like to generate my own style input tag. My code is:

     <?php
echo $this->Form->input(
                   'rpassword', array(
                   'class' => 'form-control placeholder-no-fix',
                   'type' => 'password',
                    'autocomplete' => 'off',
                    'placeholder' => 'Re-type Your New Password'
                   )
              );
        ?>

It generates HTML as follows:

 <input name="data[Reseller][rpassword]" class="form-control placeholder-no-fix " autocomplete="off" placeholder="Re-type Your New Password" type="password" id="ResellerRpassword" >

But I want to set name attribute as 'rpassword' only. My expected HTML is:

 <input name="rpassword" class="form-control placeholder-no-fix " autocomplete="off" placeholder="Re-type Your New Password" type="password" id="ResellerRpassword" >

Is there any way to do this?

Upvotes: 0

Views: 320

Answers (1)

drmonkeyninja
drmonkeyninja

Reputation: 8540

You can set the name attribute in the input parameters like 'name' => 'rpassword':-

echo $this->Form->input(
    'rpassword', array(
        'class' => 'form-control placeholder-no-fix',
        'type' => 'password',
        'name' => 'rpassword',
        'autocomplete' => 'off',
        'placeholder' => 'Re-type Your New Password'
    )
);

Upvotes: 1

Related Questions