Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
bties-ogawa opened this issue Oct 26, 2017 · 0 comments
Open

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

bties-ogawa opened this issue Oct 26, 2017 · 0 comments

Comments

@bties-ogawa
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant