Skip to content

has-error class not work in CakePHP2.9 + Bootstrap3.3.7 #83

Description

@bties-ogawa

Hi, this plugin is very cool.

I encounted a trouble that parent div class don't add class 'has-error'.

AppController.php

public $helpers = [
	'Session',
	'Html' => [
		'className' => 'BoostCake.BoostCakeHtml'
	],
	'Form' => [
		'className' => 'BoostCake.BoostCakeForm'
	],
	'Paginator' => [
		'className' => 'BoostCake.BoostCakePaginator'
	],
];

UserController.php

public function add() {
	if ($this->request->is('post')) {
		$this->User->create();
		if ($this->User->save($this->request->data)) {
			return $this->redirect(array('action' => 'index'));
		}
	}
}

View/User/add.ctp

<div class="row">
	<div class="col-sm-12">

		<?php echo $this->Form->create('User', [
			'url' => '/users/add',
			'class' => 'form-horizontal',
			'novalidate' => true,
		]);?>

		<div class="form-group">
			<label for="UserUsername" class="col-sm-2 control-label">Email</label>
			<div class="col-sm-10">
				<?php echo $this->Form->input('username', ['type' => 'text', 'div' => false, 'label' => false, 'class' => 'form-control', 'required' => false])?>
			</div>
		</div>

result

		<div class="form-group">
			<label for="UserUsername" class="col-sm-2 control-label">メールアドレス</label>
			<div class="col-sm-10">
				<div class="input text required"><input name="data[User][username]" class="form-control form-error" maxlength="50" type="text" value="" id="UserUsername"/><span class="help-block text-danger">Input email address!!</span></div>
			</div>
		</div>

My expect be add class ''has-error' in 'div.form-group'.

		<div class="form-group has-error">
			<label for="UserUsername" class="col-sm-2 control-label">メールアドレス</label>
			<div class="col-sm-10">
				<div class="input text required"><input name="data[User][username]" class="form-control form-error" maxlength="50" type="text" value="" id="UserUsername"/><span class="help-block text-danger">Input email address!!</span></div>
			</div>
		</div>

What causes can be considered?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions