how to set a default value in ckeditor 4? - ckeditor4.x

Refer to this question: https://ckeditor.com/old/forums/CKEditor-3.x/Retrieving-default-value-database
I want to set a default value in ckeditor 4, like this:
<input type="text" class="form-control" name="title" id="title" value="<!--I want to display this-->" required>
Anyone here can help?

Related

Avoiding field prepopulation in a thymeleaf form with Spring-Boot

I am having a trouble getting rid of the field prepopulation in a thymeleaf form and displaying text placeholders instead.
Here is the snippet of the form:
<form action="#" th:action="#{/catch/save}" th:object="${catch}" method="post">
<input type="hidden" th:field="*{id}">
<input type="text" th:field="*{species}" th:placeholder="Species"
class="form-control mb-4 col-3">
<input type="text" th:field="*{length}" th:placeholder="Length"
class="form-control mb-4 col-3">
<input type="text" th:field="*{weigth}" th:placeholder="Weigth"
class="form-control mb-4 col-3">
and here is the image of the resulting form:
Prepopulated form
My goal is to have the two fields prepopulated with "Length" and "Weigth". These fields correspond to int and double object fields, so if I understand correctly they are initiated with 0 when the bean is created and therefore so are th:fields when the form is loaded.
Could you help me find a way to solve this?
Thank you in advance

How to get read of automatic checked radio button in a Boolean data type in Thymeleaf, Springboot?

Im using spring-boot back-end with the fontend thyme-leaf . But the problem is when im putting Boolean data type in a radio button then the value which is set to 0 is automatically checked in the font end, event if i try to add th:checked="unchecked" its not working. My code is given bellow
<div class="form-group">
<label for="isDownloadable"> Is Downloadable</label> <br>
<input type="radio" th:field="*{isDownloadable}" value="1" th:checked="checked">Yes
<input type="radio" th:field="*{isDownloadable}" value="0"> No<br>
</div>
As here iv tried to cheack Yes radio button but its checked the No radio button in the front end.How to solve this problem ?
here is the output of my code given
If you want to use 0 and 1, you put need to condition and show data.Solution is
<div class="form-group">
<label for="isDownloadable"> Is Downloadable</label> <br>
<input type="radio" value="1" th:checked="${history.Shift == 1} ? ${true}">Yes
<input type="radio" value="0" th:checked="${history.Shift == 0} ? ${true}"> No<br>
</div>

Firefox bug with input type password?

I have a problem in an application I'm developing, if I have input fields with type 'password' then another input field is populated with data from a completely different element.
If I set the type of the element that is 'password' to 'text' there is no problem.
Unforunatley I can't post an example of jsFiddle, but I've searched around and found other people having a problem with Firefox with an older version.
I'm using version: 43.0b9 with Firebug 2.0.13
IE, Chrome and Safari do not do this with the exact same page loaded, but its very repeatable and very realiable in FireFox.
I've set the attribute autocomplete="off" but no difference.
This problem has me scratching my head...I've commented out just about everything, but the problem still occurs, some how my name and login password are finding there way into two INPUT elements, the same page in Chrome, IE and Safari does not do this.
I was having the same problem, and finally solved it after reading this answer to other similar question: https://stackoverflow.com/a/10745884/6938721
In my case, I had a lot of input fields divided into multiple fieldsets, and sent them through AJAX.
Well, the solution was to surround each <fieldset>...</fieldset> with <form>...</form> labels.
Originally I had something like:
<fieldset>
<input type="text" name="field1">
<input type="password" name="field2">
<input type="password" name="field3">
</fieldset>
<fieldset>
<input type="text" name="field4">
<input type="password" name="field5">
<input type="password" name="field6">
</fieldset>
And after applying the solution I get:
<form>
<fieldset>
<input type="text" name="field1">
<input type="password" name="field2">
<input type="password" name="field3">
</fieldset>
</form>
<form>
<fieldset>
<input type="text" name="field4">
<input type="password" name="field5">
<input type="password" name="field6">
</fieldset>
</form>
Edit:
The key is to not have more than 3 password inputs inside a <form> block. The document works as a <form> block by itself
Hope this helps

Laravel 5: validation error return values to fields

When I am creating a new entry and leave at least one field to error out then submit the form, upon validation the field values are blank.
Is there a way to return the values to their corresponding field when submitting? Something similar to CodeIgniter's set_value()?
On your form html, set the default value to
old('field_name')
Example if you are using laravel's blade:
<input class="form-control" name="name" type="text" value="{{ old('name') }}" id="name">
Example without blade:
<input class="form-control" name="name" type="text" value="<?php echo old('name'); ?>" id="name">
You can also use:
Input::old('field_name')

how to finish razor section?

I have this in my view :
<input id="#Html.TextBoxFor(m => m.UserName)" type="text" placeholder="Username" autofocus required>
<input id="(#Html.PasswordFor(m => m.Password))" type="password" placeholder="Password" required>
Its working but my result is
What am I doing wrong?
Either you want to put HTML as tags:
<input id="UserName" type="text" placeholder="Username" value="#Model.UserName" autofocus required />
<input id="Password" type="password" placeholder="Password" value="#Model.Password" required />
Or let Razor to do it for you:
#Html.TextBoxFor(m => m.UserName);
#Html.PasswordFor(m => m.Password);
You are mixing it together. Your example starts with pure HTML, then it finds the Razor command which renders another input tags, inside the pure HTML one. Prefer Razor code when you need to return the model type.

Resources