Search code examples
htmlodoorender

How to place a value inside a text area


How can I place a value inside a Textarea HTML tag in the Odoo website template views? The code I have below is not working in every case scenario, I want the text area to show a value if there is an existing value inside the project field if not then there shouldn't be a value inside the text area. I also noticed that the t-field returns the saved data in the database as rendered HTML content which is also an issue because if the data has a new line then the content inside the text area contains HTML tags e.g instead of new line <br> is shown as a value inside the text area.

<textarea class="form-control textarea-resize new_project_job_description"
                                                  id="project_job_description"
                                                  name="project_job_description"
                                                  t-field="project_job_description or project.job_description"/>

Thanks


Solution

  • Try this:

    <textarea class="form-control textarea-resize new_project_job_description"
                                                  id="project_job_description"
                                                  name="project_job_description">
        <t t-esc="project.job_description"/>
    </textarea>