Why the filepond not work as simple file type input - input-type-file

I am creating the file type input field which is looks like
<input type="file" name="jform[com_fields][logo-details-bd]" id="jform_com_fields_logo-details-bd" class="form-control filepond">
I have added the class in this field "filepond". it's replacing my filetype field. that is ok but when I submit the form, I am not getting my file. why it's happening?

Related

Validation when only spaces inserted - Foundation Abide

I`m a beginner in Foundation. I just got a task to fix issues in a form created with Foundation. And its validation is done with Foundation Abide. The issue is, in the HTML i can see "required" is added, and when we add only spaces in input field, validation accepts it as normal string. When the input field is left empty, validation working fine, it showing error message "This field is required".
I want the validation to return error "This field is required", when user enter only spaces in input field. Any idea how this is done?
<input required type="text" name="first_name" placeholder="First name">
You could just create a custom pattern matcher for the field.
Find in your code base where you're keeping your abide patterns, add something like
abide : {
patterns: {
characters_only: /[A-Za-z]+/, // this will match only letters
}
}
then add the pattern to your input element
<input required type="text" name="first_name" placeholder="First name" pattern='characters_only'>
You might have to add the error message yourself, as in -
<small class='error'>First name must only contain characters/</small>
Check here for more details -
https://foundation.zurb.com/sites/docs/v/5.5.3/components/abide.html#custom-named-patterns

Laravel custom field name in form request validation

I have a form fields in the view as:-
<input type="email" name="user[email]">
<input type="text" name="name">
<input type="text" name="designation">
While submitting this post request, I have a rule defined as:-
app\Http\Requests\StaffEditRequest.php
$rule['user.email'] = 'email|unique:users';
However, when laravel tries it to validate the request it queries the database as if there is a field name "user.email" in the users table. How to customize the field name so that I can tell laravel that I am looking for email field in the users table and not user.email?
You need to define the column in in unique parameter. Do like following:
$rule['user.email'] = 'email|unique:users,email';
Ref: Laravel Doc

List element access in spring form using index

Controller Coding
List<Map<String,Object>> rows=globalDao.list("select * from hosp_conf");
System.out.println(rows.get(0).get("hosp_id"));
model.addObject("list",rows);
return model;
View File
<input type="text" name="name" value="${rows.get(0).get("hosp_name")}" required>
I want to access my list element in spring form using specific index.
Above Sysout stament print excat value in console
How can I access it?
In jsp you can access a list index using the syntax -
${list[index]}.
In your jsp[, you need to use model attribute name that you have added at your controller.So instead of use rows you need to use list.
I don't know about the object in your list. But you can try like this -
<input type="text" name="name" value="${list[0]["hosp_name"]}" required>

How to change textboxfor's input name when we are using multiple model in MVC3?

I'm using multiple model hence textboxfor's input name is different because of multiple model so parameters are always null.
I explain what I mean as you can see at below:
#Html.TextBoxFor(model => model.managers.person_name)
I have two tables which are "manager" and "mayor_assistance" and I call these models with my class. Everything is fine at this point. But when I used these models with the TextBoxFor input name is set " manager.person_name" but my table which name is manager has a person_name column hence my parameters are always null as you can see html tag at the below
<input id="managers_person_name" name="managers.person_name" type="text" value="">
Then I have to changed tex box for input name with "new" tag, I get the same result
#Html.TextBoxFor(model => model.managers.person_name,new { #name="person_name" })
So how can I change TextBoxFor input name?
Finally I have found the answer.I want to share my solution who be faced with my problem.
TextBoxFor or something like EditBoxFor etc.. their names and ids are set by properties on the Model.Because of this you get parameter always Null!
The solution is very simple just use TextBox and put your column name as string
<div class="editor-field ">
#Html.TextBox("person_name")
#Html.ValidationMessage("person_position")
</div>

Internationalized Labels for Form Components in Wicket

How do I correctly create internationalized labels for my form components so that when displaying feedback messages an internationalized field name is displayed instead of the name of the field in the java code?
I've read this:
https://cwiki.apache.org/WICKET/everything-about-wicket-internationalization.html
as well as the documentation for wicket's xhtml tags:
https://cwiki.apache.org/WICKET/wickets-xhtml-tags.html
<label wicket:for="name">
<wicket:label>
<wicket:message key="label.name"/>
</wicket:label>
</label>
<input wicket:id="name" type="text" wicket:message="placeholder:label.name" />
This results in the following error:
Last cause: Expected close tag for '<wicket:label>' Possible attempt to embed
component(s) '<wicket:message key="label.name"/>' in the body of this
component which discards its body
If I replace the wicket:message with some arbitrary text it displays the text in any associated feedback messages.
(There's a related jira issue: https://issues.apache.org/jira/browse/WICKET-3903 however I still do not understand what has been done to fix this and what I must do ...)
Just found out there is a way to do this in java:
add(new TextField<String>("name").setRequired(true).setLabel(new Model<String>(getString("label.name"))));
Is it possible to somehow do this in a more comfortable way?
I just tested the following:
<form wicket:id="form">
<label for="input"><wicket:message key="input">some input</wicket:message></label>
<input wicket:id="input" type="text" name="input">
<input type="submit" value="submit">
</form>
And in the java class:
Form<HomePage> form = new Form<HomePage>("form"
, new CompoundPropertyModel<HomePage>(this));
wmc.add(form);
TextField textField = new TextField("input");
textField.setRequired(true);
form.add(textField);
In the property file I provided:
input=SomeInputField
This led to the following screen (if I leave the requiered field empty and press submit.
Is this what you are looking for?
Here is an alternative approach to #bert's that has always worked for me (wasn't aware of <wicket:label>)
The text shown for a FormComponent when a validation error occurs can be specified by means of FormComponent.setLabel(IModel). The shown text will be the result of the IModel's getObject().
TextField comp = new TextField("comp");
// Use internationalized text from XML resource file
comp.setLabel(new StringResourceModel("formResources.comp.label", this, null));
Notice this has nothing to do with <label> nor FormComponentLabel. FormComponentLabel is a component that can be used to model <label> tags.
You could even subclass FormComponentLabel to provide the label text based on FormComponent.getLabel(), and maybe output an extra mark when the field is required:
public class MyLabel extends SimpleFormComponentLabel{
private boolean required;
public MyLabel (String id, LabeledWebMarkupContainer labelProvider) {
super(id, labelProvider);
if (labelProvider instanceof FormComponent){
required = ((FormComponent)labelProvider).isRequired();
}
}
protected void onComponentTagBody(final MarkupStream markupStream,
final ComponentTag openTag) {
String mark = "";
if (required){
// could be for instance "*"
mark = getString("formResources.requiredField");
}
String text = getModelObjectAsString() + mark;
replaceComponentTagBody(markupStream, openTag, text);
}
}
{
TextField component = new TextField("component");
component.setRequired(true);
component.setOutputMarkupId(true);
IModel labelModel = new StringResourceModel("formResources.component.label",
this, null);
component.setLabel(labelModel);
add(component);
add(new MyLabel("componentLabel", component);
}
<label wicket:id="componentLabel"/>
<input type="text" wicket:id="component"/>
This way you would have clean way of
Setting the FormComponent's text to an internationalized resource string
Reusing exactly the same resource string transparently for the <label> tag and even adding custom marks to it based on FormComponent's properties.
Another alternative is to use the key attribute of <wicket:label/>, like so:
<label wicket:for="name">
<wicket:label key="label.name">Placeholder label</wicket:label>
</label>
<input wicket:id="name" type="text"/>
Unfortunately this attribute is not documented on the wiki page describing wicket's xhtml tags. All attributes supported are documented using JavaDoc in the class handling the tag (org.apache.wicket.markup.html.form.AutoLabelTextResolver).
The advantage of this alternative is that there is no additional coding required.
Wicket throws an exception to tell you that your <wicket:message> tag will be removed because the body of the <wicket:label> tag is replaced. The problem is you cannot nest the <wicket:message> tag inside the <wicket:label> tag (and shouldn't need to).
either this (Option 1):
<label wicket:for="name">
<wicket:label key="label.name"/>
</label>
<input wicket:id="name" type="text />
or this (Option 2):
<label wicket:for="name">
<wicket:message key="label.name"/>
</label>
<input wicket:id="name" type="text />
should work for you and result in HTML something like the following (assuming the properties file contains label.name=Name):
<label for="someMarkupId">
Name
</label>
<input id="someMarkupId" type="text" />
The difference is that if you set the label for the component through the Java code like so:
component.setLabel(new Model("value set in code"));
then using the Option 1 will result in the label being set to "value set in code", while using Option 2 will still result in the label set to "Name". Also if the label is set through Java code, and the key is missing from the properties file the Option 2 will throw an exception, while Option 1 will simply use the value set in the code.
I prefer this:
<label wicket:for="name"><wicket:label />:</label>
<input type="text" wicket:id="name"></input>
Just make sure to set the label in the FormComponent using setLabel, so the only java needed is:
add(new TextField("name", nameModel).setLabel(Model.of("i18n.name")));
This will be rendered as (in Dutch):
<label id="name63-w-lbl" for="name63">Naam:</label>
<input type="text" value="" name="name" id="name63">

Resources