cakephp2 override Form input action - cakephp-2.x

default cakephp echo $this->Form->input('name');
returns something like this
<div>
<label for="mdl.name">name</label>
<input type="text" id="mdl.name" name="mdl.name" />
</div>
but I want different let's say I want the the following
<div class="form-group more classes">
<h3>name</h3>
<div>
<span class="extra span"></span>
<input type="text" class="form-control" id="mdl.name">
<span class="extra span"></span>
</div>
<label for="mdl.name">name</label>
<span class="another span"></span>
</div>
I saw /lib/cake/view/Helper/FormHelper.php copied to app/view/Helper
but have not seen any div, label or input tags

What you might be looking for is:
echo $this->Form->input('field', array(
'before' => '--before--',
'after' => '--after--',
'between' => '--between---'
));
Which will output:
<div class="input">
--before--
<label for="UserField">Field</label>
--between---
<input name="data[User][field]" type="text" value="" id="UserField" />
--after--
</div>
Reference: CakePHP 2.x FormHelper

Related

Html Form inside another form not redirecting to the correct URL

I've the following form on JSP:
<form class="form-horizontal" style="margin-bottom: 24px">
<fieldset id="myFieldset" disabled>
<div class="form-group">
<label class="control-label col-sm-3" style="text-align: left">Created By</label>
<div class="col-sm-4">
<input class="form-control" type="text" name="created_by" value="${inputConfiguration.getCreatedBy()}" readonly/>
</div>
</div>
.
.
. few more divs of form-group
.
.
</fieldset>
<div class="form-group row">
<div class="col-sm-offset-4">
<form action="${pageContext.request.contextPath}/Configuration/EditConfiguration" method="GET">
<input type="hidden" name="marketplace" value="${param.marketplace}">
<input type="hidden" name="program" value="${param.program}">
<button class="btn btn-primary"> form_Edit </button>
</form>
</div>
<div class="col-sm-1">
<form action="${pageContext.request.contextPath}/Configuration/CopyConfiguration" method="GET">
<input type="hidden" name="marketplace" value="${param.marketplace}">
<input type="hidden" name="program" value="${param.program}">
<button class="btn btn-primary"> form_Copy to New </button>
</form>
</div>
</div>
</form>
However, the forms that are within the outer-form are not redirecting to the correct path on clicking their respective buttons. NOTE: the hidden input fields are just to pass them as url parameters to the paths mentioned in the action and nothing else. Can anyone suggest as to how to pass these as url params and how to make the nested forms work?

How can I return to a form after $request->validate() errors with the input data values showing?

I'm using this code below in a Laravel controller but on errors it doesn't keep the input data when it returns to the form.
public function store(Request $request)
{
$validatedData = $request->validate([
'name' => 'required',
'intro' => 'required|max:140|min:40',
]);
If the intro is too short it sends the user back to the form but with empty fields.
The blade looks like this
<form action="{{route('member.store')}}" id="form" role="form" data-toggle="validator" method="post">
<div class="form-group">
<input type="text" value="" class="form-control" id="name" name="name" placeholder="Name" required>
</div>
<div class="form-group">
<textarea class="form-control" id="intro" rows="2" name="intro" placeholder="A short 15-30 word intro" required></textarea>
</div>
</div>
</form>
Doesn't is come with a return to the form with the data input?
You should use old('input') in the value of the input.
For your code it should be like this:
<div class="form-group">
<input type="text" value="" class="form-control" id="name" name="name" placeholder="Name" value="{{ old('name') }}" required>
</div>
<div class="form-group">
<textarea class="form-control" id="intro" rows="2" name="intro" placeholder="A short 15-30 word intro" value="{{ old('intro') }}" required></textarea>
</div>

Angular Form Validation error : form is undefined

I am trying to validate my data for a student object with Angular Form Validation, but when I want to use or print for example, the serialNumber of a student it gives me this error: Cannot read property 'serialNumber' of undefined.
Here is the code:
<div *ngIf="student">
<div class=container>
<h2>Student {{student.name}} details</h2>
<form name="studentForm" (ngSubmit)="save()">
<!--<div ng-class="{ 'has-error' : studentForm.serialNumber.$invalid && !studentForm.serialNumber.t">-->
<label>Serial number: {{student.serialNumber}} </label>
<input type="text" name="serialNumber" class="form-control" ng-model="student.serialNumber" required>
<div ng-messages="studentForm.serialNumber.$error">
{{studentForm.serialNumber}}
<p ng-message="required">Your name is required!</p>
</div>
<!--</div>-->
<div>
<label>Name: {{student.name}}</label>
<input ng-model="student.name" placeholder="name">
</div>
<div>
<label>Group number: {{student.groupNumber}}</label>
<input ng-model="student.groupNumber" placeholder="groupNumber">
</div>
<button (click)="goBack()">Back</button>
<button (click)="save()">Save</button>
</form>
</div>
</div>
The ng-messages and ng-model attribute directives do not exist in Angular 2+. I would recommend reading into Angular Forms, ReactiveForms, and Template Syntax.
If you would like to dual data-bind the input values, you can do so with the following syntax: [(ngModel)]="student.serialNumber". However, in Angular 2+, there are usually better ways of getting values other than explicitly data-binding.
Angular Form Validation template Driven Model
onSubmit(form : NgForm) {
console.log(form);
}
<form #form="ngForm" (ngSubmit)="onSubmit(form)"
[ngClass]="{'was-validated': form.invalid && (form.dirty || form.touched)}">
<div class="" ngModelGroup="User">
<h2 class="text-center">Registration page</h2>
<br />
<div class="form-group">
<input type="text" class="form-control" placeholder="First Name" name="firstname" required
ngModel #firstname="ngModel">
<span class="help-bpx" *ngIf="firstname.touched && !firstname.valid ">Please enter the
firstname</span>
</div>
<div class="form-group">
<input type="text" class="form-control" placeholder="Last Name" name="lastname" required ngModel
#lastname="ngModel">
<span class="help-bpx" *ngIf="lastname.touched && !lastname.valid ">Please enter the
lastname</span>
</div>
<div class="form-group">
<input type="email" class="form-control" id="email" placeholder="Email" name="email" email
required ngModel #email="ngModel">
<span class="help-bpx" *ngIf="email.touched && !email.valid ">Please enter the Email
Value</span>
</div>
<div class="form-group">
<div class="custom-file">
<input type="file" class="custom-file-input" id="customFile" required ngModel name="file" #file="ngModel">
<label class="custom-file-label" for="customFile">Choose file</label>
</div>
</div>
<br />
<div class="align-center">
<button type="submit" class="btn btn-primary" [disabled]="!form.valid">Register</button>
</div>
</div>
</form>

HTML form not sending parameters

I wrote a login panel for my website and everything looks fine but when I click on submit page refreshes and no parameters are being sent. I checked both get andpost methods but it's not working. here is my code:
<form id="login_form" action="index.php?task=login" method="post">
<div class="control-group">
<div class="controls">
<div class="input-prepend">
<span class="add-on"><i class="icon-user"></i></span>
<input class="span2" id="username" type="text" value="Username" onblur="if(this.value=='') this.value='Username'" onfocus="if(this.value=='Username') this.value='';">
</div>
</div>
</div>
<div class="control-group">
<div class="controls">
<div class="input-prepend">
<span class="add-on"><i class="icon-cog"></i></span>
<input class="span2" id="password" type="password" value="Password" onblur="if(this.value=='') this.value='Password'" onfocus="if(this.value=='Password') this.value='';" />
</div>
</div>
</div>
<div class="clear"></div>
<div class="separator"></div>
<button type="submit" class="btn">Login</button>
</form>
Can anyone tell me what is wrong with my code?
Your input tags don't have the name attribute which is required to post the value.
<input type="text" name="username" />

Need to change smarty file into zend file

HI here i have smarty file and i need to convert into zend..
How can i change smarty to zend? its tpl file
<div id="add-user-form" class="form">
<form action="/account/login" method="post">
{{input_text type="hidden" name="redirect_url" value=$smarty.server.REDIRECT_URL|default:"/"}}
<div class="contain">
<div class="fieldgrp">
<label> </label>
<div class="field"><p><h3>Enter User Credentials</h3></p></div>
</div>
<div class="fieldgrp">
<label for="login_name">Username </label>
<div class="field">{{input_text name="login" id="login_name" class="longfield" maxlength="100"}}</div>
</div>
<div class="fieldgrp">
<label for="login_password">Password </label>
<div class="field">{{input_text type="password" name="password" id="login_password" class="longfield" maxlength="100"}}</div>
</div>
<div class="fieldgrp">
<label> </label>
<div class="field"><input type="submit" value="Login" /></div>
</div>
</div>
</form>
You can replace the Smarty code with the HTML it generates....
eg.
{{input_text name="login" id="login_name" class="longfield" maxlength="100"}}
becomes
<input type="text" name="login" id="login_name" class="longfield" maxlength="100">
But past that, this question doesn't really make a lot of sense.