如何在CakePHP 3.4中禁用元素的抖动DIV?
现在看起来像:
<div class="input text">
<input type="text" name="query" placeholder="Search" id="query">
</div>
但它应该看起来像
<input type="text" name="query" placeholder="Search" id="query">
PHP代码:
<?= $this->Form->control("query", array(
"label" => false,
"placeholder"=>__("Search")));
?>
我该怎么做?
答案 0 :(得分:0)
<?php
echo $this->Form->control('query', array(
'div' => false,
'label' => false,
'placeholder' => __('Search')));
?>
答案 1 :(得分:0)
您可以使用CakePHP表单Template
自定义自动生成的HTML
代码。
示例:add.ctp
$custom_template = [
'button' => '<button{{attrs}}>{{text}}</button>',
'checkbox' => '<input type="checkbox" name="{{name}}" value="{{value}}"{{attrs}}>',
'checkboxFormGroup' => '{{label}}',
'checkboxWrapper' => '<div class="checkbox">{{label}}</div>',
'dateWidget' => '{{year}}{{month}}{{day}}{{hour}}{{minute}}{{second}}{{meridian}}',
'error' => '<div class="error-message">{{content}}</div>',
'errorList' => '<ul>{{content}}</ul>',
'errorItem' => '<li>{{text}}</li>',
'file' => '<input type="file" name="{{name}}"{{attrs}}>',
'fieldset' => '<fieldset{{attrs}}>{{content}}</fieldset>',
'formStart' => '<form{{attrs}}><div class="box-body">',
'formEnd' => '</div></form>',
'formGroup' => '{{label}}{{input}}',
'hiddenBlock' => '<div style="display:none;">{{content}}</div>',
'input' => '<input type="{{type}}" name="{{name}}"{{attrs}}/>',
'inputSubmit' => '<input type="{{type}}"{{attrs}}/>',
'inputContainer' => '<div class="form-group {{type}}{{required}}"><div class="form-line">{{content}}</div></div>',
'inputContainerError' => '<div class="input {{type}}{{required}} error">{{content}}{{error}}</div>',
'label' => '<label{{attrs}}>{{text}}</label>',
'nestingLabel' => '{{hidden}}<label{{attrs}}>{{input}}{{text}}</label>',
'legend' => '<legend>{{text}}</legend>',
'multicheckboxTitle' => '<legend>{{text}}</legend>',
'multicheckboxWrapper' => '<fieldset{{attrs}}>{{content}}</fieldset>',
'option' => '<option value="{{value}}"{{attrs}}>{{text}}</option>',
'optgroup' => '<optgroup label="{{label}}"{{attrs}}>{{content}}</optgroup>',
'select' => '<select class="form-control" name="{{name}}"{{attrs}}>{{content}}</select>',
'selectMultiple' => '<select name="{{name}}[]" multiple="multiple"{{attrs}}>{{content}}</select>',
'radio' => '<input type="radio" name="{{name}}" value="{{value}}"{{attrs}}>',
'radioWrapper' => '{{label}}',
'textarea' => '<textarea name="{{name}}"{{attrs}}>{{value}}</textarea>',
'submitContainer' => '<div class="submit">{{content}}</div>',
];
$this->Form->templates($custom_template);
echo $this->Form->input('name',['type'=>'text']);
以上模板将生成以下HTML:
<div class="form-group text">
<div class="form-line">
<label for="name">Name</label>
<input name="name" class="form-control" id="name" type="text">
</div>
</div>
的文档