Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8891237
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:41:20+00:00 2026-06-14T22:41:20+00:00

I have a field that I would like to be read-only and have a

  • 0

I have a field that I would like to be read-only and have a default value.

here what I have till now:

    object passwd extends MappedString(this, 20) 
    {
       override def defaultValue = "XXX" + Random.alphanumeric.take(12).mkString // some default value
//  readOnly = true // Or something similar??? 
    }

I tried overriding toHtml, asHtml, toForm, displayHtml but they all change the view or the label or something else.

I just want the defaultValue to be automatically generated (which works) but the users not to be able to edit that field when create/editing the entity.

Any advice would be very much appreciated

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T22:41:21+00:00Added an answer on June 14, 2026 at 10:41 pm

    Got it,

    Just override _toForm and disable the input element:

    import net.liftweb.http.S
    
    override def _toForm =  
        S.fmapFunc({s: List[String] => this.setFromAny(s)}){name =>  
        Full(<input disabled='disabled' type='text' id={fieldId} maxlength={maxLen.toString}  
        name={name}  
        value={is match {case null => "" case s => s.toString}}/>)}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to have a text field that a user can enter a
I have an array that I would like to sort using a date field
I have a field that is in this format 5551112391^HUMAN^HUMAN-800-800^6-main^^ How would I only
I have to convert an incoming String field into a BigDecimal field that would
I have 3 similar tables, that would all have the same enum type field.
I have a field that may be blank, so I need to use Object.try,
I have a Django Model with a text field. I would like to modify
I have a class that defines a read-only property that effectively exposes a private
In my form I have one read-only field. The content of the field will
I have an html form that looks something like this: <div class=field> <input id=product_name

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.