Formhelper to add a line Break in cakephp - cakephp

The Form helper in cakephp
echo $form->input('Firstname', array('class'=>'test','name'=>'Firstname','type'=>'text'));
generates me like the following
<div class="input text">
<label for="Firstname">Frrstname</label>
<input type="text" id="Firstname" value="" class="test" name="Firstname"/>
</div>
is it possible to add a Break between label and input within the DIV .. If so how .. please suggest

I would suggest not adding the break.
Just use css:
label{display:block}
would achieve the same result.

echo $form->input('Firstname', array( 'between'=>'<br />','class'=>'test','name'=>'Firstname','type'=>'text'));

Related

Disable tooltip "Please fill out this field" when not using <form> tag (DNN)

Setting 'novalidate' or 'formnovalidate' will NOT fix this issue
I'm using the framework DNN. This framework wraps each page in a form tag which breaks my custom forms. To get passed this I'm using ng-form on a tag. Because of this fix I always see the default tooltip even though I'm using bootstraps uib-tooltip. I'm willing to go as far as jQuery to fix this issue however I read a post where apparently Chrome and Firefox have both disabled the ability to select and edit the default tooltips. Example:
<div role="form" ng-form="myForm" novalidate>
<div class="form-group">
<label>
<input type="text" id="Identifier" name="Identifier" ng-minlength="3" ng-maxlength="14" class="form-control" ng-model="$ctrl.Identifier" ng-required="true" uib-tooltip="{{ $ctrl.tooltips.identifier }}" tooltip-enable="myForm.Identifier.$invalid && myForm.Identifier.$touched">
</label>
</div>
</div>
Displays "Please fill out this field". How can I remove the default tooltip?
Thanks to this post by jscher2000 I was able to find a work around. Simply add a 'title' tag and set it's contents to an empty space. Simply passing in empty quotes doesn't work there must be at least 1 space between the quotes that's empty. Example:
<input type="text" name="Name" title=" ">
Thanks.

using ng-mask for phone

I still have doubt in using ng-mask, I went through most of the web pages for it to work but it still remains the same. And many people told to use it with input tag of angularjs, after doing so Im not able to mask the input.Or am I making mistake please somebody correct me and give the clarity of using the ng-mask.
<input type="tel" name="phoneno" maxlength=13 ng-model="phone.number" ng-mask="(999)999-9999"/>
</div>
<button class="button2" ng-click="home()">Back</button> &nbsp &nbsp &nbsp
<button class="button3" ng-click="addphone()">Add</button>
Download the ngMask.min.js from net
Call the ngMask.min.js before app.js and Include app.js module
var yourApp= angular.module("yourApp", [
'ngMask'
]);
HTML :
<input type="tel" name="phoneno" maxlength=13 ng-model="phone.number" mask="(999)999-9999" />
Below code is working for me.
I think you should use data-on attribute like below
<input type="text" class="form-control input-small" data-ng-model="zipcode" placeholder="Enter the zip code" data-ng-mask="#####-###" data-on="keyup">
// 2. Add ngMask module dependency to your app.
angular.module('yourApp', ['ngMask']);
<!-- 1. Add ngMask plugin after your AngularJS. -->
<script src="angular.min.js"></script>
<script src='ngMask.min.js'></script>
<!-- 3. Use the avaiable patterns to create your mask. Set the mask attribute. -->
<input type='text' ng-model='maskModel' mask='39/19/9999' />
<!-- 4. Adjust your mask options. -->
<input type='text' ng-model='maskModel' ng-value='0/3/9' mask='3/9?' mask-repeat='2' mask-restrict='accept' mask-clean='true' mask-validate='false' mask-limit='false' />
source: https://github.com/candreoliveira/ngMask/blob/master/README.md
Use ui-mask instead:
<div class="form-group">
<label for="birth-date">Date of birth</label>
<input type="text"
class="form-control"
id="birth-date"
ng-model="formData.date_of_birth"
ng-value="formData.date_of_birth"
ui-mask="99.99.9999"
ui-mask-placeholder
ui-mask-placeholder-char="_"
>
</div>
https://github.com/angular-ui/ui-mask

Can i use an expression from ctrl in default input value in angularjs?

Can i use an expression from controller $scope in default input value in angularjs?
i mean something like this.
<input name="somename" id="someid" type="hidden" ng-model="tempmodel" ng-init="tempmodel={{ datafromcontroller.field }}">
i need a hidden input field with some default data. In a plain html with php would be something like..
<input name="somename" id="someid" type="hidden" value="<?php $var ?>">
Thank u and sorry for my english xD
I tried this and works!
<input name="somename" id="someid" type="hidden" ng-model=datafromcontroller.field>

Set a default value with angular js

I have an field where the id is set via php:
<input name="user_id" type="text" value="<?php echo $this->r->user_id; ?>" ng-model="entry.user_id" >
But the value does not appear in the field.
How can I set it from php to angular js?
Set the initial value of the ng-model using ng-init instead:
<input name="user_id" type="text" ng-model="entry.user_id" ng-init="entry.user_id = <?php echo $this->r->user_id; ?>" >
I'm not sure about the php syntax, but this will set value for you as long as the controller has an entry object available.
<input type="text" ng-model="enquiry.companyName" ng-init="enquiry.companyName='<?php echo $_SESSION['COMPANYNAME'] ?>'" name="companyName">
Sigle quote around php block is important.
You might want to try ng-value as well. Might fit your situation better. I didn't come across it until today:
<input name="user_id" type="text" ng-value="<?php echo $this->r->user_id; ?>" ng-model="entry.user_id" >

Cakephp - Change validation errors div structure?

Is there any way of changing the validation error div structure? I want to insert an image just before the div.
Each error will be displayed inline with the input field, so I want to insert a left arrow image before the validation div.
Currently I am getting this:
<div class="input password required error">
<label for="StudentPassword1">Password</label>
<input type="password" name="data[Student][password1]" value="" id="StudentPassword1" class="form-error">
<div class="error-message">notempty</div>
</div>
I'd like:
<div class="input password required error">
<label for="StudentPassword1">Password</label>
<input type="password" name="data[Student][password1]" value="" id="StudentPassword1" class="form-error">
<img src='...' />
<div class="error-message">notempty</div>
</div>
How would you accomplish this? I'm guessing that I have to modify the core? Thanks
I'm guessing that I have to modify the core?
No. If your app requires changing Cake's core you are likely doing something wrong. Cake has a lot going on and it takes care of a lot of things for you. This happens to be one of the things you can customize to your liking.
When you create your Forms with the FormHelper you can specify default options for input() and one of those options includes the HTML structure and class used to wrap error messages.
I would just modify the CSS of the error-message class to include the image.
.error-message {
background:url( path/to/img.png ) no-repeat top left;
padding-left:40px; /* or whatever you need for the image to fit */
}
<?php echo $this->Form->create('User', array('class'=>'form-horizontal',
'inputDefaults' => array('error' => array(
'attributes' => array(
'wrap' => 'label', 'class' => 'text-error'
)
) )
)); ?>
This will make you customize the error output.

Resources