0

I am having dificulties creating some form defaults with the FormHelper of CakePHP2.

I have some input fields which I want to be readonly, and some select boxes to be disabled.

I have the following code this far:

echo $this->Form->create(
    'User',
    array(
        'novalidate' => true,
        'inputDefaults' => array(
            'div' => false,
            'placeholder' => '...',
            'readonly' => 'readonly'
        )
    )
);

This code is setting my select boxes to readonly. How can I target input and select boxes individually?

4

1 回答 1

0

我认为您只需要将 readonly 放入 options 数组中,如下所示:

echo $this->Form->input('Field', array ("label" => '', 'id'=> '', 'readonly'=>'readonly'));

与禁用相同:

echo $this->Form->input('Field', array ("label" => '', 'id'=> '', 'disabled'=>'disabled'));

就是这样;D

于 2013-11-28T15:50:49.533 回答