Remove default value of Material UI - material-ui

I am learning NextJS as well as Material UI. I have a Form. Code of Email and PassWord field of the Form is like below.
<TextField
label="Email"
variant="outlined"
type="email"
required
/>
<TextField
label="Password"
variant="outlined"
type="password"
required
/>
I am getting output like below
I would like to remove these Default Values.
How can I remove those Default Values?

Related

Material-UI hide input & add min/max character length

I have a text input field and a sign up button. Since it's a password the user is going to enter in the field I want the input to be hidden. Any ideas on how to implement this feature?
I also want the field to be sort of disabled if the length of the password is less than 5 characters and longer than 12. (UPDATE: SOLVED IN BACKEND!)
I would be able to figure out at least the min and max length if I was using ''normal'' frontend styling, but I'm trying out Material UI for the first time and I can't really find the right information on how to make this work now.
<TextField
id="Password"
label="Password"
value={password}
onChange={handlePasswordChange}
variant="outlined"
/>
<Button variant="contained" color="primary">
Sign up!
</Button>
Add the type attribute like this:
<TextField
id="Password"
label="Password"
type="password"
value={password}
onChange={handlePasswordChange}
variant="outlined"
/>

Material UI InputLabel - disable animation when input is empty

When my input field is empty and not focused, Material UI would place the label inside the input field as a placeholder.
What I want is, to have the label above the input field all the times, similarly to what it looks like if the input field is selected.
How can I do this?
Example code:
<FormControl>
<InputLabel htmlFor="name">Name</InputLabel>
<Input name="name"
value={name}/>
</FormControl>
For those looking for how to achieve this with TextField component, here:
<TextField
variant="outlined"
InputLabelProps={{
shrink: true,
}}
/>
After 30 mins of pulling my hair... I finally got it. The property you are looking for is not called disableAnimation as one could thought, it's the shrink property. API docs - https://material-ui.com/api/input-label/
<FormControl>
<InputLabel htmlFor="name" shrink='true'>Name</InputLabel>
<Input name="name"
value={name}/>
</FormControl>

DHTMLX SCHEDULER

[enter image description here][1] I want to add Time period section to fully custom light box.
[<form id='form1'>
<span class="label">Text</span><input id="Text1" name="text" type="text"/><br />
<span class="label">From</span><input id="start_date" name="start_date" type="text"/>
<span class="label">to</span><input id="end_date" name="end_date" type="text"/><br />
<span class="label">Room_id</span><input id="Text4" name="room_id" type="text"/>
<span class="label">User Id</span><input id="Text5" name="user_id" type="text"/>
<input type="text" id="patient_name" name="patient_name"/>
<input type="text" id="patient_dob" name="patient_dob"/>
<input id="Hidden1" name="id" type="hidden"/>
</form>][1]
[1]: SEE this Image https://i.stack.imgur.com/A3spf.png
It shouldn't be very difficult
you need to find a date-time picker component that works for you
(datepicker embedded into dhtmlxScheduler lacks time-picker
functionality)
when user opens lightbox - you initialize datepickers in form inputs and assign event.start_date/end_date into them
when user saves lightbox - you get values from datepickers and update event.start_date/end_date with those values.
Here is a demo - http://docs.dhtmlx.com/scheduler/snippet/5e45f342
I used this example https://docs.dhtmlx.com/scheduler/samples/02_customization/16_custom_form.html and flatpickr datepicker https://chmln.github.io/flatpickr/ for it.

Inconsistent primefaces commandbutton behaviour

Using the following code I get an behaviour that I can't explain.
The autocomplete method works fine to select an object.
It updates the panel below as expected.
But then the two buttons (New Airport, Save Airport) are not firing the backing bean listener.
However if I click on one of the buttons before using the autocomplete to load an object, the listener gets fired.
<h:form id="arptForm">
<p:autoComplete minQueryLength="3"
value="#{airportHandler.theAirportNames}" effect="fade"
completeMethod="#{airportHandler.autoComplete}"
forceSelection="true" converter="airportNamesConverter"
var="airport" itemLabel="#{airport.icaoName}" itemValue="#{airport}"
maxResults="#{airportHandler.maxAutoCompleteResults}">
<f:ajax event="itemSelect"
listener="#{airportHandler.airportChanged}" render="#form" />
<p:column style="width:80%">
<h:outputText
value="#{airport.icaoName} - #{airport.iataName} - #{airport.airportName} (#{airport.cityName})" />
</p:column>
</p:autoComplete>
<p:spacer width="20" height="20" />
<p:commandButton id="newAirport" value="New Airport"
icon="ui-icon-newwin" actionListener="#{airportHandler.newAirport}"
update="#form" />
<p:spacer width="20" height="20" />
<p:commandButton id="saveAirport" value="Save Airport"
icon="ui-icon-newwin" actionListener="#{airportHandler.saveAirport}"/>
<p:separator />
<p:outputPanel id="allArptData">
<p:panel id="airportBasics" header="Airport Basics"
toggleable="true" toggleSpeed="500"
rendered="#{airportHandler.theAirport != null}">
<ui:include src="airportbasics.xhtml" />
</p:panel>
<p:panel id="airportRunways" header="Airport Runways"
toggleable="true" toggleSpeed="500"
rendered="#{airportHandler.theAirport != null}">
<ui:include src="airportrunways.xhtml" />
</p:panel>
</p:outputPanel>
</h:form>
Can you explain what happens ?
Thanks
As you said you should not the nest forms that is not correct. Also when you put everything inside a one main form that means you are mixing the processes while submitting that form. There can be lot's of forms per a page like autocomplete form or profile information form etc.
When you do sth. about autocomplete actually you want to submit things about autocomplete not about other buttons so simply seperate them. That does not mean you should have forms for each component but just seperate your page into main sections.

Spring sf form tags how to change type?

This gives me error prone HTML code, because Spring automatically generates text type, how do I change this behaviour?
<td><sf:input type="password" path="password" size="20" maxlength="30" /><br />
<sf:errors path="password"cssClass="error" />
</td>
html code generated:
… name="password" **type="password" type="text"** value="" size="20" maxlength="30" …
Use the password tag
This tag renders an HTML 'input' tag with type 'password'
<form:password path="password" />
For details
The password tag