how can I to add an html formatted string on a vaadin label so that it looks pretty?
It must be formatted with bold text, italic text, new lines, html things basically.
I'm using Vaadin 14. Thank you so much in advance!
You'll want to use new Html("");
Label corresponds to <label> and should only be used to label input fields.
Have you tried something like this:
Label label = new Label();
label.getElement().setProperty("innerHTML","Just a sentence before a line break <br /> <b> bold text</b> <br /> <i> italic text</i>");
Or this:
String yourContent = "Just a sentence before a line break <br /> <b> bold text</b> <br /> <i> italic text</i>";
Html html = new Html("<text>" + yourContent + "</text>");
Related
I have been testing 'react-text-mask' library and I want to use this component together with ant design Input component using its render attribute. However, it doesn't show formatted text.
<TextMask
mask={[/[12]/, /\d/, /\d/, /\d/, "-", /[01]/, /\d/, "-", /[0-3]/, /\d/]}
placeholderChar="_"
showMask
render={(ref, props) => (
<Input
name="phone"
className="form-control"
placeholder="Hey I am Ant design Input"
required
ref={ref}
{...props}
/>
)}
/>
If I change the tag with It shows formatted text like we expect.
My main intention to show every input component should be displayed like an ant design component.
demo
You can make it using react-input-mask library.
While using struts2 tags I wrote jsp as
<s:textfield name="NumOfSeats" label="No. of Berths"/>
<sx:datetimepicker name="date" label="Date of journey" displayFormat="dd-MM-yyyy" />
<s:textfield name="trainNo" label="Train no"/>
I got my page like this(Lables and textfilelds at same height)
As I need datetimepicker I added this <sx:head></sx:head>. Then page became like this(label and text field at different heights)
What can I do for making them to align at same height.
How can i enable a Break Line or New Line in Textarea when i press the Enter Key ?
So that if I press the ENTER it saves in the form of New Line in database.
I have already searched some topics but it hasn't helped me.
Here is my Textarea Code:
<textarea name="post" id="post" class="valid Post_Text_Area" placeholder="Write something here..." ></textarea>
I tried this JS Code so far. but it hasn't worked for me
JavaScript: How to add line breaks to an HTML textarea?
Newlines in textarea's are saved into the database by default.
To generate them as Html BR codes, use nl2br($yourTextVariable) $yourTextVariable will be the variable you fetch from database. so use it like this :
<?php echo nl2br($yourTextVariable); ?>
This transforms newline to <br />
Another solution is put the output into <pre> tag or just style it with css white-space: pre. It will not swallow multiple spaces.
In Zend Framework 2.1.4 I am using the standard form view helpers to render out my form elements.
When I try:
<?php echo $this->formRow($form->get('Title'));?>
The label text and input element are placed within the label:
<label>
<span>Title</span><input type="text" name="Title" placeholder="Inserisci titolo"
required="required" value="">
</label>
The same with:
<?php echo $this->formCollection($form, TRUE);
However, if I render out the label and input individually:
echo $this->formLabel($form->get('Title'));
echo $this->formInput($form->get('Title'));
It generates the html I want:
<label for="Title">Title</label>
<input type="text" name="Title" placeholder="Insert Title" required="required" value="">
How can I achieve the same with the formRow view helper?
If a form element does not have an "id" attribute, the label will wrap the input:
<label>Label<input /></label>
Otherwise:
<label for="test">Label</label><input id="test" />
Looking at (zf2 version 2.25 dev):
\Zend\Form\View\Helper\FormRow
It appears that if you don't provide an id for your form elements, the default general behaviour is to place the input element inside their corresponding label element.
The second argument for the formRow view helper, will place the label text before (prepend) or after (append) the input element in the document flow. (The default is to place it before.)
Check the render method for more details.
In first you must look source code to understand how formRow works : https://github.com/zendframework/zf2/blob/master/library/Zend/Form/View/Helper/FormRow.php
After you'll see in this code that __invoke has $labelPosition parameter that you can prepend or append with const LABEL_APPEND and LABEL_PREPEND.
In short, try to do something like this :
$this->formRorw($form->get('element'), 'prepend'); // Or append as you want
Is it possible to use html in Foundation's tooltips?
Yes. It supports html in the title attribute.
from foundation.tooltip.js:
create : function ($target) {
var $tip = $(this.settings.tip_template(this.selector($target), $('<div></div>').html($target.attr('title')).html())),
...
Breaking that down it creates a new element wrapped in a div and the contents of the title attribute are inserted into the div using the html() method which will convert any markup in the string to html elements.
The following code:
<img src="example.png"
class="general-infotip has-tip tip-top"
data-tooltip
title="<b>This is bold</b> This is not" />
Will result in a tool tip that looks like
This is bold This is not
In Foundation v6.3+, you can append the attribute data-allow-html="true" to the element to allow html in the tooltip.
For example:
<span data-tooltip data-allow-html="true" aria-haspopup="true"
class="has-tip" data-disable-hover="false" tabindex="1"
title="Fancy word for a <strong>beetle</strong>. <br><br><img src=https://pbs.twimg.com/profile_images/730481747679432704/uc08_dqy.jpg />">
Scarabaeus
</span>
Here it is working in jsfiddle.
For more information, check out the pull request.