0

I'm trying to itlic the text inside a Php condition but it's not working as it displays the tags instead of applying it. And I only want the Text to be italic to be italic, but if the other value was true $this->input->getinput() then no italic needed.

<input
        type="text" required
        class= "form-control"
        id   = "id"
        name = "name"
        value= "<?php echo (!empty($this->input->getinput()))?  $this->input->getinput(): '<a style="text-align: center"><i>Text to be italic</i></a>'?>"
        title = "title"
/> 
Tak
  • 3,536
  • 11
  • 51
  • 93

2 Answers2

4

You cannot use styles into value sub tags

Please try below code

<input
        type="text" required
        class= "form-control"
        id   = "id"
        name = "name"
        <?php echo (!empty($this->input->getinput())) ?  ' value="'.$this->input->getinput().'" ' : ' style="font-style: italic" value="Text to be italic" '; ?>
        title = "title"
/>
Ivan Barayev
  • 2,035
  • 5
  • 24
  • 30
0

You are not allowed to make some tag eg. <i>some text</i> inside value attribut. You want it

<input type="text" value="<a style="text-align: center"><i>Text to be italic</i></a>">

,isn't it? But there is way to make it by CSS. Follow this How to make value text in form be italic.

Or this another reference HTML in the input field value

Community
  • 1
  • 1