Redux Form FieldArrays autofill - redux-form

I'm using a field array which consists of email fields. It looks like this:
{fields.map((member, index) => (
<li key={index}>
<div className="form-group d-flex align-items-start">
<Field
name={`${member}.email`}
type="email"
component={renderField}
placeholder="Email"
/>
</div>
</li>
))}
On Chrome, when you autofill one field with a stored email, it autofills the rest with the same email.
For the time being, I've turned off autocomplete, but this is not working. I would like a better way to do this, so that users can autofill a given field, but the rest of them are not autofilled.

Related

How to use multidimensional checkbox v-model in vuejs

Suppose i have some subjects which has conditions and groups.
How can i load those first time and checked in update mood in vuejs?
<div v-for="(sub, Index) in subjects">
<b>{{ sub }} </b>
<label v-for="(subconlist) in sub['subCon']">
<input type="checkbox"
:value="subconlist.id"
:key="subconlist.id"
>
<span>{{subconlist.name}} </span>
</label>
<label v-for="clsgrlist in sublist['acGr']">
<input type="checkbox">
<span>{{clsgrlist.academic_group_name}} </span>
</label>
</div>
<button #click="saveOrUpdate()" >Save </button>
</div>
fiddle here
the table where i will save it : sub_id,condition_ids,group_ids
I have to save data based on checked value in the table with comma separated.
How can i get checkbox checked if it already found in the table, i mean when update?
I need to get subjectconditon or group ids basis on each subject when click on save button.

how to get current user data only in laravel

i am working on laravel and want to get only login user data but when i change code it give error in my view
public function index(){
$users = User::all();//Auth::user();//
//dd($users);
return view ('profile.index',compact('users'));
}
this is the code that give output and show all user data
when i change the code the error it give me no output
this is image
this is view i am using
<div class="container">
<div class="row">
<div class="container" >
<h2>Basic Details<h2>
<form>
#foreach($users as $user)
<image src=" {{$user['image']}}" class="img-circle">
<div class="form-group col-lg-3">
<span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>
<h4>Name:</h4>
<input type="text" value="{{$user['name']}}" class="form-control" id="text" name="text"
readonly="true">
</div>
<div class="form-group col-lg-3">
<h4 for="Email">Email:</h4>
<input type="email" value="{{$user['email']}}" class="form-control" id="email" name="email"
readonly="true">
</div>
#endforeach
</form>
There are several issues with your code and, as #pseudoanime commented, you can't directly interchange the single user case vs. all users because of the returned data types. However, if you REALLY want to do this, you could change things up so that both situations return a collection, as shown below:
public function index(){
$users = collect(Auth::user());
return view ('profile.index',compact('users'));
}
I'm not sure why you would want to do this rather than simply returning a different view, but I'll leave that up to you. Please note that I would suggest re-evaluating your problem and taking a different approach, as it makes no sense to loop through a collection you will know only has a single member.
Additionally, you should note that you are not accessing the user model properly. You are using array syntax in the view (for example, $user['email']) when you should be using object syntax ($user->email). There are other issues with the code that may still cause issues, but this is the most obvious problem I see.

Recognize multiple object using single xpath using attributes H3 and label text

I'm trying to recognize two objects on two different UI using a dynamic xpath.
So object are as in snippet:
<div class="reports-filter">
<ul id="portfolio-input--temp-ddisable">
<li>
<h3 class='reportOptions'><label>Enter Account Number</label></h3>
<input id="name2" name="name2" type="text" value="" size="20"/>
</li>
</ul>
<input type="hidden" name="secure" value="true"/>
</div>
<div class="multiCol">
<h3 class='reportOptions'><label>Account Number </label></h3>
<input id="reportFilters17.typeSpecific.string" name="reportFilters[17].typeSpecific.string" class="textFilter" type="text" value=""/>
</div>
Now i tried used following xpath but to no luck
//h3[contains(text(),'Account Number$']
//h3[contains(.,'Account Number$']
//h3[#class='reportOptions']
//h3[#class='reportOptions']/text()
//label[contains(.,'Account Number$')]
.//*[contains(text(),'Account Number$')]
why are you using $ in contains function if you want to check end with number then use matches and second thing use //h3[#class='reportOptions']/label or //h3[#class='reportOptions']/label/text()

How to Apply form validation inside data table in angular2

I am trying to apply required field validation for text-box which is inside data table template.
Required field validation message pop up properly but as there is no form tag i was not able to check form.valid in component.
Please find below code:
<data-table id="user-grid"(reload)="reloadItems($event) [items]="userData">
<data-table-column [header]="'UserName'">
<template #dataTableCell let-item="item">
<span>
<input type="text" [(ngModel)]="item.UserName" class="form-control" required #UserName="ngModel" name="UserName"/>
<span class="text-danger" *ngIf="(UserName.errors != null && UserName.errors.required && (UserName.dirty))">
Please enter user name.
</span>
</span>
</template>
</data-table-column>
<data-table-column [header]="'Action'" >
<template #dataTableCell let-item="item">
<a title="Save" (click)="save(item)" class="btn green btn-sm">
</a>
</template>
</data-table-column>
</data-table>
Any help will be appreciable.
Put the datatable element inside the form tag having ngForm. It would fire the form validations.
Please see below:
<form #testform="ngForm">
<data-table>
</data-table>
</form>

Laravel: textarea does not refill when using Input::old

I am experiencing that only the Input Textfields respond as expected when I write the code to repopulate a form (when errors were found for example) or when from a table row I click in the Edit button and I go to an editable form. The field for a textarea is not repopulated so it comes up empty, therefore, if I save it, I would delete the content of the textarea. (I know I am asking a succession of questions lately, the reason is that I have basically finished my application and I left for the end the minor things I could not solve, so my apologies for that).
here is an example of what I am saying:
This WORKS for input textfield:
WORKS
<div class="col-md-4">
<label for="relato">Charges</label>
<input type="text" name="expenses" maxlength ="30" class="form-control"
value = "{{ $user->expenses }}"/>
</div>
That is, the $user->expenses fills the textfield of the form that comes up when clicking the Edit button of a table row.
However, that does not work for a textarea field:
<div class="row">
<label for="relato">Description</label>
<textarea name ="message" id="message" rows="5" cols="100" value = "{{ $user->message }} class="form-control"
</textarea>
</div>
See? that part $user->message will not pass the content to the textarea of a form.
Similarly: with Input::old
Works for an Input textfield
WORKS
Email: <input type="text" class="form-control" name="email" {{ (Input::old('email')) ?' value ="' . e(Input::old('email')). '"' : '' }}>
DOES NOT WORK FOR TEXTAREA
<div class="form-group">
<label for="relato">Une petite description</label>
<textarea id="message" name = "content" rows="10" cols="50" onKeyPress class="form-control" {{ (Input::old('content')) ?' value ="' . e(Input::old('content')). '"' : '' }}
">
</textarea>{{ $errors->first('content')}}
</div>
And the controller is also trying to refill the form by sending ->withInput
if($validator->fails()){
return Redirect::route('usersgetformtopostads')
->withErrors($validator)
->withInput();
}
but, as I said, it only works for textfields. Does not repopulate me a select list or a textrarea
By the way, I have looked a related question here where the author says he could not repopulate a File field and he was told that "you cant" and he gave that as a correct answer, however, I have been able to repopulate Files uploaded, not having any problem with that.
textarea does not have a value attribute. Values in textarea should be inside <textarea></textarea>, so in your case:
<textarea id="message" name = "content" rows="10" cols="50" onKeyPress class="form-control">
{{{ Input::old('content') }}}
</textarea>
Just figured it out, put the old value in between the brackets as below
<textarea name="message">{{ old('message') }}</textarea>
This is another way to do the same but with the Forms component from laravel:
{{ Form::textarea('content',Input::old('content'),array('id' => 'message')) }}
I'd like to add one thing, if you use Form Class for the form and elements then you don't need to explicitly right the Input::old('element-name') to retrieve the value of the previous form submission.
Just use
{{ Form::text('name', null, array('id'=>'name', 'class' => 'class-to-apply')) }}
And you're good to go.
Here, null value for the text field will be null for the first time, and if you redirect back this page with input then this will automatically grab the value.
Sorry for late reply
{{Form::textarea('mobile_message', isset($notifications -> mobile_message) ? $notifications -> mobile_message : null, 'id'=> 'mob_id','class' => 'form-control'))}}
<div class="control-group hidden-phone">
<label class="control-label" for="textarea2">Category Description</label>
<div class="controls">
<textarea style="resize:none" name="category_description" required rows="6">
<div class="control-group hidden-phone">
<label class="control-label" for="textarea2">Category Description</label>
<div class="controls">
<textarea style="resize:none" name="category_description" required rows="6" >{{$category_info->category_description}}</textarea>
</div>
</div>
</textarea>
</div>
Normally, textarea does not have a value attribute, but there's a way you can add that with the current Laravel version (which is 8+)
<textarea>{{{ Request::old('content') }}}</textarea>

Resources