You are viewing limited content. For full access, please sign in.

Question

Question

Single line Field in between text

asked on January 5, 2017 Show version history

Is there an easy way to create a single line field within a paragraph. Right now I am using CSS but it gets a little clunky. Example below.

 

Hello my name is                                      (legal name) I                              (legal name) want to apply for this position.

Not sure if this question has been asked before. If so please attach a link.

 

2 0

Answer

SELECTED ANSWER
replied on January 6, 2017 Show version history

Here's another alternative, it requires some Javascript to actually add your paragraph, but it should get the look and feel that you are going for...

On your layout, just add the single line fields, the HTML text will get added via Javascript.

*EDIT* - give both fields a CSS Class of: inline-field

 

Here's the CSS (*EDIT* this is has been changed based on @████████'s suggestion to use CSS Class Name instead of Field ID):

/*hide the labels to the left of the two single line fields*/
.inline-field .cf-label {display : none;}

/*set the sizing of the two single line fields, 
increase or decrease these values as desired*/
.inline-field input {width : 180px; min-width : 180px;}

/*minimize the padding around both of the fields*/
ul li.inline-field {padding-left : 2px; padding-right : 2px;}
ul li.inline-field {padding-bottom : 0px; padding-top : 0px;}
.inline-field .cf-label {padding : 0px;}
.inline-field input {padding : 0px;}

/*set both fields to display in an inline-block*/
.inline-field {display : inline-block;}

/*remove left, right, and top borders, so that
fields look like a blank line rather than a text box*/
.inline-field input {border-style : solid;}
.inline-field input {border-top-width : 0px; border-left-width : 0px;}
.inline-field input {border-right-width : 0px; border-bottom-width : 1px;}

/*center align text in the fields*/
.inline-field input {text-align : center;}

 

Here's the Javascript (with some Lorem ipsum added in to demonstrate a longer paragraph):

$(document).ready(function () {
  
  $('#q1').before("Hello my name is");
  $('#q1').after("(legal name) I");
  $('#q2').after("(legal name) want to apply for this position. Lorem ipsum dolor sit amet, consectetur adipiscing" + 
                 "elit. Fusce est felis, pellentesque vitae mauris sit amet, sagittis feugiat est. Donec vitae " + 
                 "sollicitudin justo. Fusce pharetra orci vitae massa accumsan, vitae bibendum arcu maximus. Sed " + 
                 "quis vestibulum quam. Donec vehicula eu orci et sagittis. Etiam tincidunt lacinia nisi eu " + 
                 "consequat. Ut congue vel nunc et iaculis. Aenean ut purus finibus, lobortis ante sed, consequat " +
                 "nisl. Nunc orci ipsum, molestie eu felis sed, finibus laoreet magna. Nunc pharetra mi at nulla " +
                 "fermentum porttitor.");
  
});

 

And this is the end result:

9 0
replied on January 6, 2017 Show version history

Functionally I like this method the best - only one form is needed and you don't need to juggle between custom inputs and Forms fields. I'm just averse to referencing fields by ID. For the JavaScript this is unavoidable unless you give unique classes to each field, but the CSS could be cleaned up if you also assign a class like ".inline-field" to #q1 and #q2:

/*hide the labels to the left of the two single line fields*/
.inline-field .cf-label {display : none;}

/*set the sizing of the two single line fields, 
increase or decrease these values as desired*/
.inline-field input {width : 180px; min-width : 180px;}

/*minimize the padding around both of the fields*/
/**
  Edit: need to use "ul li.inline-field" selector
        instead of just ".inline-field" to avoid
        being overridden by a more specific built-in rule
**/
ul li.inline-field {padding-left : 2px; padding-right : 2px;}
ul li.inline-field {padding-bottom : 0px; padding-top : 0px;}
/**
  Edit: shorthand method:
  ul li.inline-field {padding: 0px 2px;}
**/
.inline-field .cf-label {padding : 0px;}
.inline-field input {padding : 0px;}

/*set both fields to display in an inline-block*/
.inline-field {display : inline-block;}

/*remove left, right, and top borders, so that
fields look like a blank line rather than a text box*/
.inline-field input {border-style : solid;}
.inline-field input {border-top-width : 0px; border-left-width : 0px;}
.inline-field input {border-right-width : 0px; border-bottom-width : 1px;}
/**
  Edit: shorthand method:
  .inline-field input {border: 0px solid; border-bottom-width: 1px;}
**/

/*center align text in the fields*/
.inline-field input {text-align : center;}

Another advantage of this method is that if you elect to implement a drop-down field inline, the set-up is the same and you do not need to recreate the select element separately in custom HTML. In the above CSS, all references to "input" would have to be modified to "select" in that case.

3 0
replied on January 6, 2017

Yeah, hopefully somewhere down on Laserfiche's todo task we might have some type of "field in between text concept thing". LOL! 

0 0
replied on January 6, 2017 Show version history

Now that's what I'm talking about! @████████

1 0
replied on January 6, 2017

You've got a great point @████████about using CSS class names instead of field IDs.  Lines 9 and 10 for the field padding aren't working in the script you posted, and I'm not sure why (yet), but otherwise I really like it.

0 0
replied on January 6, 2017

There's a more specific built-in rule which is overriding it, thanks for catching that. The lines can be modified as follows:

ul li.inline-field {padding-left : 2px; padding-right : 2px;}
ul li.inline-field {padding-bottom : 0px; padding-top : 0px;}
/**
  shorthand method:
  ul li.inline-field {padding: 0px 2px;}
**/

Thanks!

1 0
replied on January 6, 2017 Show version history

Yep - that did it.  Great!

I'm glad @████████asked this question, I'm gunna keep this in my back pocket for later.

I'm going to edit my earlier post with the corrected CSS script.

2 0
replied on January 6, 2017

I have another question brewing if you want to get in on this. I love to stir the pot. wink

https://answers.laserfiche.com/questions/113391/Tool-Tip-to-Table-Rows

0 0
replied on December 18, 2017

This is great!  Any tips on how to change the font of the .before and .after text?  Like font itself, font size, bold, underline, etc...?

0 0

Replies

replied on January 5, 2017

This is the best option I can come up with...

I think because of the way forms has individual elements for fields, it'll be hard to make it a true flow with the fields embedded within the paragraph.  The way @████████ recommended gets the appearance down right, but as @████████ indicated, you'll lose the field controls without some Javascript to recreate them.  

This way will allow you to use the built-in Single Line fields in forms, but it won't truly flow, I had to break the paragraph into four pieces.

First, add the two Single Line fields (with Extra Large Width) and four Custom HTML fields with your text, like this:

Be sure when you are doing the custom HTML fields that you enter the text on the HTML tab (as opposed to the Visual tab) without any HTML tags.

Then, enter this as your CSS for the form:

/*set all six fields to display in an inline-block*/
#q1, #q2, #q3, #q4, #q5, #q6 {display : inline-block;}

/*hide the labels to the left of the two single line fields*/
#q2 .cf-label, #q4 .cf-label {display : none;}

/*set the sizing of the two single line fields, 
increase or decrease these values as desired*/
#Field2, #Field4 {width : 180px; min-width : 180px;}

/*minimize the padding around all of the fields*/
#q1, #q2, #q3, #q4, #q5, #q6 {padding : 1px;}
#q2 .cf-label, #q4 .cf-label {padding : 0px;}
#Field2, #Field4 {padding : 0px;}

And voila!

2 0
replied on January 6, 2017

Yes, this is the current way I have it. Multiple fields. Its just kinda mess when you need to update something. One word changes and it throws off the look. I might possibly have three to four boxes within a contract paragraph. @████████ is it possible to get this in a future update.

0 0
replied on January 6, 2017

You could pull the information from the HTML text box and put it in a single line field that could been hidden from the user.

textbox in html.PNG
textbox in html2.PNG
0 0
replied on January 6, 2017

@████████ would this same look be saved to Laserfiche. I want the fields to stay filled out. I know HTML fields don't transfer over.

0 0
replied on January 6, 2017

Hi Chynna,

I've forwarded your request to the Forms team as a future enhancement, though I would warn that realistically, support for it is not likely to come soon as it would involve a departure from the current way that forms are generated, so implementation would not be trivial.

I had tried without success to find an alternate way of setting this up but for now, I believe Matthew's method is the best way so far, clunky as it may be. You are correct that the custom HTML element will not preserve the input values when saved to a repository, even though in principle this could be a method to collect the values to store to process variables.

1 0
replied on January 6, 2017

@████████ thanks for the input. I totally understand, that this is not at the top of the list. I am just glad we are able to find the best practices through Answers! smiley

0 0
replied on January 6, 2017 Show version history

Actually, my recent reply gave me a new idea that builds off of Dylan's method and I think is more elegant than Matthew's. Instead of using one form...why not two?

Form 1: What the user submits

Add a custom HTML element. I gave mine the CSS class ".customHtml" and the following HTML code:

<p>Hello my name is <input id="real-name" type="text"> but you can call me <input id="nick-name" type="text"> if you dare.</p>

Then add two single-line fields, corresponding to the two fields in this custom HTML element. I gave mine the CSS classes ".field-real-name" and ".field-nick-name", respectively. They have the respective variable names Real_Name and Nick_Name.

Then add the following custom CSS to hide these:

/* Can remove this for diagnostic purposes */
.field-real-name,
.field-nick-name {display: none;}

And the JavaScript to align the custom HTML input elements with our Forms fields that store the variable values:

$(document).ready(function() {
  //  initialize inline field values with values of hidden Forms fields
  $('.customHtml #real-name').val($('.field-real-name input').val());
  $('.customHtml #nick-name').val($('.field-nick-name input').val());
  
  //  when the inline field value changes, update the corresponding hidden Forms field
  $('.customHtml #real-name').on('change',function() {
    $('.field-real-name input').val($(this).val());
  });
  $('.customHtml #nick-name').on('change',function() {
    $('.field-nick-name input').val($(this).val());
  });
});

At present, if we save this form, while the variable values would be updated, the custom HTML area would still be blank. So the solution? Save a different form!

Form 2: What is saved to the repository

Make a copy of the original form. You can remove the two Forms fields; we no longer need them. You can also remove the custom CSS and JavaScript from the previous step as they are unnecessary (if you have others, you'll probably want to keep them).

Then edit the custom HTML as follows:

<p>Hello my name is {/dataset/Real_Name} but you can call me {/dataset/Nick_Name} if you dare.</p>

Since we now have access to these variables, we can replace the input elements with the values we've collected! Now we just have to save this form instead of the one the user submitted.

The Save-to-Repository Sleight-of-Hand

Now in the Process Designer, instead of choosing the starting form from a process step, choose to save a form with current process data. [01-str-config.png]

And that's it! I've attached two additional screenshots showing what the user sees when filling out the form, and the saved form in the repository. [02-form-submit.png and 03-form-stored.png, respectively]

The only caveat now is that in the form preview with the thank you message, it will still show the submitted form so the input fields would appear blank...I'm not sure if this is acceptable or not.

Hope this helps!

01-str-config.png
02-form-submit.png
03-form-stored.png
2 0
replied on January 6, 2017

Working with two forms is not ideal...But it isn't a bad idea. The major problem that you pointed out would be the blank fields upon submission. I definitely don't want a contactor to fill out the form and then assume they didn't type anything. Because if they need to print it out, they won't have a completed application. I really don't want to create process that saves, emails, and deletes documents. That would just junk up a process to me.

0 0
replied on January 6, 2017

All valid concerns...see Matthew's more recent edition to his previous method which does not create additional elements for surrounding text, but adds them using JavaScript.

2 0
replied on July 27, 2017 Show version history

Hey Matthew.  I tried to recreate this form for a form I am building.  Everything works as expected but the submission wraps the field value:

Filling out the Form:

Form in the repository:

I am using the same code as used above in your example.

0 0
replied on July 27, 2017

In the Layout page of your form.  What size are your fields?  Are they the default Medium? or something else?  Do you get the same result if you set the size to extra large?

It's been ages since I worked on this form, and I didn't test all the way through posting to the repository, but looking at your screen shot, it looks like it could be an issue with field width...

0 0
replied on July 28, 2017

Yes I expanded the field to be the largest it can be.  It helped but is still wrapping the words.

 

0 0
replied on July 28, 2017 Show version history

@████████- I think the problem is in the CSS I provided before.  Some of the attributes are applied specifically to the input elements.  The problem is that the input elements do not exist on the version of the form that is submitted to the repository (and also inside Forms when viewing a previously submitted form).  Here's a modified version of the CSS that duplicates some of the settings from the input fields to the .cf-field class (which always exists, one level above the input).  I also moved the bottom border line away from the input element and onto the .cf-field element.  You should get the same appearance with this CSS in both the live form and the archival form.

/*hide the labels to the left of the two single line fields*/
.inline-field .cf-label {display : none;}

/*set the sizing of the two single line fields, 
increase or decrease these values as desired*/
.inline-field input {width : 180px; min-width : 180px;}
.inline-field .cf-field {width : 180px; min-width : 180px;}

/*minimize the padding around both of the fields*/
ul li.inline-field {padding-left : 2px; padding-right : 2px;}
ul li.inline-field {padding-bottom : 0px; padding-top : 0px;}
.inline-field .cf-label {padding : 0px;}
.inline-field input {padding : 0px;}
.inline-field .cf-field {padding : 0px;}

/*set both fields to display in an inline-block*/
.inline-field {display : inline-block;}

/*remove left, right, and top borders, so that
fields look like a blank line rather than a text box*/
.inline-field input {border-style : solid;}
.inline-field .cf-field {border-style : solid;}
.inline-field input {border-top-width : 0px; border-left-width : 0px;}
.inline-field .cf-field {border-top-width : 0px; border-left-width : 0px;}
.inline-field input {border-right-width : 0px; border-bottom-width : 0px;}
.inline-field .cf-field {border-right-width : 0px; border-bottom-width : 1px;}

/*center align text in the fields*/
.inline-field input {text-align : center;}
.inline-field .cf-field {text-align : center;}

 

0 0
replied on July 31, 2017

Adding the input didn't change the submission image.  Still looks wrapped as I have in the picture.

If there another feature of CSS that will hold the field settings for the submitted view?  

Input seems to be just that but is it not overriding the .cf-field?

0 0
replied on July 31, 2017

Are you using the full CSS that I provided, or just part of it, or your own CSS?  If your own, do you mind sharing what you are using?

0 0
replied on July 31, 2017
/*set both fields to display in an inline-block*/
#q6, #q7 {display : inline-block ; vertical-align:top;}

/*hide the labels to the left of the single line field*/
.inline-field .input {display : none;}
.inline-field .cf-label {display : none;}

/*set the sizing of the field, 
increase or decrease these values as desired*/
.inline-field input {width : 180px; min-width : 180px;}
.inline-field .cf-field {width : 180px; min-width : 180px;}

/*minimize the padding around field*/
ul li.inline-field {padding-left : 2px; padding-right : 2px;}
ul li.inline-field {padding-bottom : 0px; padding-top : 0px;}
.inline-field .cf-label {padding : 0px;}
.inline-field input {padding : 0px;}
.inline-field .cf-field {padding : 0px;}

/*set field to display in an inline-block*/
.inline-field {display : inline-block;}

/*remove left, right, and top borders, so that
fields look like a blank line rather than a text box*/
.inline-field input {border-style : solid;}
.inline-field .cf-field {border-style : solid;}
.inline-field input {border-top-width : 0px; border-left-width : 0px;}
.inline-field .cf-field {border-top-width : 0px; border-left-width : 0px;}
.inline-field input {border-right-width : 0px; border-bottom-width : 0px;}
.inline-field .cf-field {border-right-width : 0px; border-bottom-width : 0px;}

/*center align text in the field*/
.inline-field input {text-align : center;}
.inline-field .cf-field {text-align : center;}

Since the field is associated with the inline-field class it's pretty much a copy paste.  

I only modified the input bottom width px=0 from your px=1 so the bottom border goes away.

0 0
replied on July 31, 2017

Hmmm...  Interesting, it worked differently for me.

Rather than continue the discussion here, can you post a new question for this?  That'll be useful in getting input from others.  I've been responding here because I am subscribed to this question, but a new question will be more easily viewed by others.  You can copy the URL from this post and refer to it in the new question's post.  Please include your full Javascript and CSS in that new post.

Hopefully with assistance from others besides myself we can get this worked out for you.

1 0
replied on April 10, 2019

I am trying the same solution but it is not working for me.  I am getting a line break after the single line field.  any help is greatly appreciated.

Capture.PNG
Capture2.PNG
Capture3.PNG
Capture.PNG (19.78 KB)
Capture2.PNG (13.12 KB)
Capture3.PNG (9.49 KB)
0 0
replied on January 5, 2017

Hi Chynna,

Having <input type="text" name="name" value=""> in the custom HTML should work.

 

~Dylan Mathiesen

replied on January 5, 2017

If you just use this method, it will not save the values anywhere.

It might be possible to use javascript to save the values entered here to a hidden field, but if you want the Form to look like this when saved back to Laserfiche, that will not help.

You are not allowed to follow up in this post.

Sign in to reply to this post.